Design and developer tools4 min read

Prism

A component system that makes its behaviour inspectable: spring motion, shared overlays, three visual expressions and recorded AI response states.

Built with React, TypeScript, Spring Physics, Browser Top Layer

Prism screenshot

From components to a system

The interesting part of Prism is no longer an individual button. It is whether inputs, menus, dialogs and asynchronous responses behave like they belong to the same product. I moved the work towards shared behaviour: typed APIs, spring motion, a common overlay layer and visual expressions held to the same interaction contracts.

Keep the behaviour, change the expression

A different visual language should not require a different keyboard model or props API.

  • Separate component implementations

    Each expression could evolve independently, but behaviour would need to be checked and repaired in several places.

  • Shared behaviour with distinct expressionsChosen

    Keep the interaction contract and vary the presentation. Test that contract across the expressions.

The expressions become a test of the component system rather than separate galleries. Visual variety has to survive the same behavioural checks.

Let the browser own the layer

A panel inside a transformed or clipped ancestor can disappear regardless of its z-index. Closing a native overlay immediately also cuts off its exit motion.

  • Portals and larger z-index values

    Move each panel manually and manage its stacking outside the browser top layer.

  • Top layer with shared dismissal and presenceChosen

    Use manual popovers and native dialogs, with a shared dismiss stack and spring presence. Prefer CSS anchor positioning where supported, with a measured JavaScript fallback.

Escape dismisses the top layer. Closing panels stay mounted through their exit spring. Modal focus return and scroll locking belong to the shared layer, rather than each component inventing them.

Show the engineering

X-ray makes hit targets, focus order, roles, contrast and springs visible while exploring a component. Its overlay joins the top layer too, so opening a dialog does not hide the inspection tools. This exposes implementation choices; it does not certify accessibility or replace testing.

Make AI behaviour repeatable

An AI response interface needs to handle waiting, tool calls, partial answers, interruption and failure. A fresh model response on every visit would make those states difficult to compare and introduce a running cost.

  • Call a model on every visit

    Fresh output, but variable timing, variable content and a model bill attached to a public demo.

  • Replay recorded local-model eventsChosen

    Record real local Ollama output, preserve event timing and feed it through an abortable stream interface.

The demo can be stopped, retried and inspected without a paid call. An injected tool timeout is labelled, and a wrong-source run remains visible as a failure. The interface presents response state; it does not verify whether a model claim is true.

AI interfaces beyond the answer bubble

The AI response component makes tool arguments inspectable, reveals streamed text at an even pace, links citations only when a source exists and announces the completed answer once to screen readers. Latency states and the async button share timing rules for fast starts, slow requests and retry; settled states ignore late results. Token Compose explores a different boundary: a seeded generator produces layouts from a closed token vocabulary, and a validator rejects off-token values. It is deterministic generation, not an LLM choosing a layout, and the validator checks membership rather than taste or contrast.

Installable, and what comes next

Eight components install straight into a project with the shadcn CLI, for example npx shadcn@latest add https://prism.sammii.dev/r/prism-menu.json: async button, AI response, dialog, sheet, popover, tooltip, toast and menu. Each item carries the shared hooks it needs, such as overlay.ts, anchor.ts and assistant.ts, and a test compiles every item outside the app to prove it stands alone. The next form primitives and a shared OKLCH token contract are still to come.