Hooks
The hooks used by Onset components, importable for building custom components.
Onset components use these hooks internally. They are exported so custom components can use the same behavior.
State
Controlled and uncontrolled prop pairs.
Overlay behavior
Dismissal, focus, and scroll locking for overlays.
Anchor and panel refs, open state, dismissal, and trigger ARIA attributes.
useDismissOutside-click and Escape dismissal, with an allow-list of refs that do not count as outside.
useEscapeKeyRuns a callback on Escape while enabled.
useScrollLockFreezes background scroll while an overlay is open.
useFocusTrapKeeps Tab inside a container, with initial focus and restore on close.
SSR
Rendering the same markup on server and first client paint.
False on the server and the first client render, true after hydration.
useIsomorphicLayoutEffectuseLayoutEffect on the client and useEffect on the server.
Refs & navigation
Ref merging and roving keyboard navigation.
Combines several refs into one callback ref.
useListNavigationArrow-key navigation state for menus and listboxes.
Pointer & layout
Reading pointer gestures, element sizes, and motion preferences.
Pointer dragging with capture, cancellation, and listener cleanup.
useElementSizeAn element's content-box size, tracked through resizes.
useReducedMotionWhether the reader has asked for less motion, tracked live.
Forms
Reading the state a form group or field publishes.
Reads the nearest FormGroup's shared tone, disabled, required, and id prefix.
useFieldInvalidTells a custom control whether its enclosing Field is in an error state.
Tiling
Editing a tile layout and reading the enclosing tile cell.
Holds a MosaicGrid's layout, its undo history, and the add / remove / reset operations around it.
useMosaicTileCell dimensions of the enclosing MosaicTile.
Flows
Multi-step flow state without built-in UI.
Virtualisation
Computing which rows to render for a given scroll offset.
Theming & portals
Reading and changing the resolved theme.
Resolved theme values, configuration, and update functions.
usePortalContainerPortal container within the current theme.
Toast & command palette
Imperative APIs owned by a provider.