Skip to content

Primitives

The internal building blocks M3 components are made from, exported for custom controls.

import { useM3SpringValue, useM3SpringValues, useEntrance, useKeepPressedInPlace, useNearestReveal, usePageHeight, useReorder, useSliderTouchTrack, useScrollRestoration, useScrollKeys, useLabels, useRevealEntering, useM3Interaction, useM3Morph, useM3Spring, usePresence, useKeyboardInset, useTriggerProps } from '@windmorph/react/primitives';

What primitives are

Primitives are the internal building blocks the M3 components are assembled from — interaction, structure, overlay plumbing and the shape/morph engine. They are also published from a separate @windmorph/react/primitives entry for building custom controls that must match M3 behaviour (ripple, focus ring, state layers, elevation, morphing shapes) without re-implementing it.

Reach for primitives only when a finished component does not fit — a bespoke control, a new surface, a custom morphing graphic. If an M3 component (Button, TextField, Dialog…) covers the need, use it; it already wires these primitives together correctly.

Because the docs site is restricted to the public M3 entries (it imports only the precomputed shape outlines from primitives, for the shape table), this page has no live demos and no generated props table. Sections Live examples and Props are therefore not applicable here; the snippets below are illustrative strings. The authoritative API lives in the source and TSDoc under packages/react/src/primitives.ts.

Layer boundaries & rationale

  • The library is built in layers, with dependencies pointing only downward (enforced by eslint-plugin-boundaries): tokens → utils → theme / motion → primitives → components → composites. A composite is built only from public components, so it may not import primitives directly; there is none at present. ButtonGroup, which takes the page's direction from a primitive, is a component.
  • src/shapes is pure geometry that imports nothing, so both primitives and components may use it. Primitives are internal first; the @windmorph/react/primitives entry exposes them for advanced consumers, kept separate from the main M3 entry.
  • These are not M3 components, so they carry no M3 spec guarantees — they are the mechanism M3 components are built from. Non-M3 finished components live instead under @windmorph/react-pro; primitives are a lower layer than that.