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';Keyboard
| Key | Action | Where |
|---|---|---|
| Enter or Space | Presses a ButtonBase button, including the div form (as="div", role="button"), or switches a toggle.ButtonBase | ButtonBase |
| Enter | Follows a ButtonBase link (href).ButtonBase | ButtonBase |
| Enter or Space | Presses the element through React Aria's usePress, and starts the ripple from the centre, unless you pass isPressed from another hook, which then handles the keys.useM3Interaction | useM3Interaction |
DomDirectionLocale gives React Aria the element's laid-out direction (the same locale with its script changed, keeping its hour cycle and calendar; its digits are the new script's, so a React Aria number or date-segment input of your own there reads Latin digits), so arrow keys follow an RTL layout. The components inside still write and read their dates, times and numbers in the page's locale, as useLocale gives it to your own formatting; a calendar day's name holds its date as the page writes it, and only React Aria's own words there, such as “selected” around that date or the calendar grid's month name, follow the changed locale.
Screen reader
- Role
ButtonBaseis abutton, alinkwithhref, or adivwithrole="button".useM3Interactionadds no role: it is presentation only.ErrorTexthas thealertrole, andFieldErrorIcontheimgrole.- Accessible name
ButtonBasetakes its name from its content or youraria-label.FieldErrorIconis named by its requiredlabel("Error" in M3).CharacterCounteris read as itslabel, and hidden from assistive tech without one.- States announced
ButtonBaseannounces disabled, and pressed or not pressed for a toggle (aria-pressed). An overlay trigger hands itaria-haspopup,aria-expandedandaria-controlsthroughTriggerContext.
TouchTargetis hidden from assistive tech (aria-hidden).ErrorTextis announced as it appears, because of itsalertrole; pass anotherroleto change that.Overlayportals its content todocument.body, keeping the theme anddirof where it was rendered. PasstopLayerfor content that must stay reachable above a modal, as tooltips do.
Focus
useM3Interactionsetsdata-focus-visibleon keyboard focus, not pointer focus. Thefocus-ringutility draws a 3pxsecondaryoutline 2px outside the element from it, andfocus-ring-insetthe same ring inside, for full-bleed rows.- A disabled
ButtonBasecannot be focused.preventFocusOnPresskeeps focus where it is on press, as menu triggers do. Overlayrestores focus to where it was when its content unmounts, unlessdisableFocusManagement. Containment comes from the React Aria hook of the component using it, and is released while it animates out (exiting, from theisExitingthatusePresencereturns).
Touch target
TouchTarget adds an invisible hit area 48px tall and at least 48px wide (the element's width if wider), centred on the control, without changing its layout. Render it inside the control's relative content wrapper, never on the root.
Motion
- The
state-layerripple appears at full size without growing under reduced motion.container-motionsnaps corner morphs, while colours and elevation still fade. - Under reduced motion the spatial spring tokens (
--md-sys-motion-spring-spatial-*-duration, and so theduration-m3-spatial-*utilities) are 0ms, so anything that moves, resizes, reshapes or turns on them changes at once; the effects springs keep their durations, so fades and colour changes still run. useM3Springreturns thestandardscheme, which never visibly overshoots, under reduced motion; skip spatial animations yourself, as the components do. Themotion-standard:variant applies under the standard scheme (data-motion="standard") or reduced motion.usePresencetakes several end properties, so an exit that slides normally and fades under reduced motion can end on either.useM3Morphleaves reduced motion to you: snap itsprogressinstead of springing it.
What you need to do
- A control built on
useM3Interactionowns its semantics: pair it with the matching React Aria hook for its role, accessible name and state. - Use
focus-ring(orfocus-ring-inset) on every focusable element you build, andTouchTargeton any control smaller than 48px. - Name icon-only
ButtonBasecontrols witharia-label, and wrap a component whose arrow keys must follow the layout inDomDirectionLocale.