Motion token reader

@interlace/ui — reads the `--ease-*` and `--duration-*` tokens from an element, so animations started from script retune with the brand like the CSS does.

foundationserverlibv1.0.0
Visual examples + interactive variants
View Motion token reader on Storybook
No embeddable story for this item yet.
→

Install

Two equivalent paths — the URL works in any shadcn-CLI setup; the alias works once you've registered @interlace in your components.json.

Via shadcn URL
npx shadcn@latest add https://ds.interlace.tools/r/motion-token.json
With the @interlace alias
npx shadcn@latest add @interlace/motion-token

History

This component is at v1.0.0, first shipped in @interlace/ui 2.0.0. The version is stamped as a banner into the file the install writes, so the copy in your tree says which one you have — compare it with the number above before deciding whether to re-run the install.

Import

4 named exports — pull the parts you need.

Public API
import { MotionDuration, MotionEase, motionDuration, motionEase } from '@/lib/motion-token';

Accessibility

Every story for this component is rendered headlessly and checked with axe-core (wcag2aa, wcag22aa, best-practice, ACT) on every PR. That gate has no continue-on-error, so what ships has zero known violations.

What follows is what static analysis can see. Axe cannot press a key and never sees an overlay open, so the operable-without-a-mouse claim lives in Behavior instead, where the keyboard path is replayed step by step.

Focus + keyboard behaviour
Native element semantics — no interaction layer to get wrong.
Focus ring (WCAG 2.2 SC 2.4.13)
Not focusable — no focus indicator required.
Reduced motion
No animation to gate.
ARIA in the source
None — semantics come from the element or the Base UI primitive rather than hand-written ARIA.

Dependencies

Base UI primitive
Native / no Base UI dependency
Lucide icons
none
NPM dependencies
none
Registry dependencies
none

Source

The full implementation — lib/motion-token.ts once installed.

43 lines · TypeScript
const EASE = {
  enter: 'cubic-bezier(0.16, 1, 0.3, 1)',
  exit: 'cubic-bezier(0.5, 0, 0.75, 0)',
  move: 'cubic-bezier(0.65, 0, 0.35, 1)',
} as const;

const DURATION = { fast: 100, base: 150, medium: 250, slow: 400 } as const;

export type MotionEase = keyof typeof EASE;
export type MotionDuration = keyof typeof DURATION;

/** Called where an animation starts, which is always in the browser. */
const read = (el: Element, name: string): string => getComputedStyle(el).getPropertyValue(name).trim();

/** The brand's `--ease-{name}` on `el`, for a Web Animations `easing`. */
export function motionEase(el: Element, name: MotionEase): string {
  return read(el, `--ease-${name}`) || EASE[name];
}

/** The brand's `--duration-{name}` on `el`, in milliseconds. */

…23 more lines…

Registry JSON

The raw registry record — what the shadcn CLI fetches.