Category
Visual Design
Interaction Design
Software Engineering

Published
Apr 9, 2026

Updated
May 23, 2026

Read
3 min

ContourContainer.ts

Origins

I've been working on a personal digital assistant and agent fleet management tool since December. I call her/it Ora. Over the past month I've been gradually picking off polish items—many of which would never see the light of day in typical software. Ora isn't typical software.

As you can tell from the video below, Ora's details, aesthetics, and sci-fi bent give her a unique feel. A feel more commonly found in polished video game UIs. This is the level of polish I'm after.

Ora Overview

As mentioned and highlighted in the video, I have the concept of a "railed attachment". One of the polish items related to this RailedAttachment.tsx that was queued—and I've since implemented—is the ContourContainer.tsx. Here's a vid highlighting it:

ContourContainer Highlight

Contours

If you're familiar with HTML & CSS then you're familiar with wrapping and related layout rules. You'll also know that the box model—though simple and powerful—is restrictive and boring. I wanted a container that updated at runtime while additionally contouring around its children. Back in the day (~10yrs ago) I wrote a small JavaScript lib that used SVG at runtime to replace boring boxes with what I called Slurves (slants + curves). You can check that article here and see a sample below.

SlurveJS Example

Slurve Card Examples

The contour container I envisioned could leverage this same basic concept while being expanded upon with more intelligence.

ContourContainer.ts was born.

Below is a screenshot example where the image attachment context and file chip context are within a single ContourContainer.tsx instance that itself is inside a RailedAttachment.tsx instance:

Contour Container Example

ContourContainer.tsx Example

You can additionally view a vid of the demo app below or launch and play with it yourself.

ContourContainer.ts Demo App

Launch App

Code

The implementation of ContourContainer.ts lacks dependencies by design. As a result you can snag the source and use ContourContainers in your web-based vanilla or framework-based stack. Here's a high-level overview of the cast:

Core — framework-agnostic, zero dependencies:

  • generatePath.ts — pure function. Section rects + style config → SVG d string. Bezier transitions between sections of differing cross-axis size; degenerates to a rounded rectangle when sections are uniform.
  • parseStyles.ts — DOM utility. getComputedStyle() → structured visual values: border, radius, padding, gap, drop-shadow, transition.
  • types.ts — shared TypeScript types.

React wrapper — one possible adapter; the core is framework-agnostic:

  • ContourContainer.tsx — React component. Wraps N children, hosts the SVG, wires measurement → path → render.
  • useChildMeasurements.ts — React hook. ResizeObserver + MutationObserver watch the children; emits SectionRect[] + container size, batched via requestAnimationFrame.
GitLab - ContourContainer.ts