Skip to Content
⭐️ Leave a star →
HooksOverview

Hooks

Wire UI ships a set of small, focused React hooks. They are the same building blocks the components are made from — exported so you can compose your own headless UI with identical behaviour, accessibility, and data-* conventions.

State

HookPurpose
useControllableStateUnified controlled / uncontrolled state.
useDisclosureBoolean open / close with stable handlers.
useIdSSR-safe unique id with optional prefix.
usePreviousThe value from the previous render.
useStateMachineTyped finite state machine with state / send / can.
useUndoRedoBounded history with undo / redo / canUndo / canRedo.

Interaction

HookPurpose
useClickOutsideFire a callback on outside click / tap.
useFocusTrapTrap keyboard focus inside a container.
useFocusVisibleTrack keyboard-vs-pointer focus.
useInteractiveStateHover, focus-visible, press state with data-* attributes.
useKeyboardMap keyboard events to handlers with modifier support.
useHotkeysDeclarative shortcut binder with mod+k, scopes, input-suppression.
useLongPressLong-press gesture handler with move-cancel and threshold.
useCopyToClipboardAsync clipboard write with copied flag and auto-reset.

Layout

HookPurpose
useFloatingPosition a floating element relative to a reference.
useScrollLockLock document scrolling without layout shift.

Observers

HookPurpose
useIntersectionObserverObserve element visibility within a scroll container.
useResizeObserverObserve an element’s content-box size.
useMutationObserverObserve DOM mutations on a ref target.
useElementSizeLive { width, height } of a referenced element.
useWindowSizeLive { width, height } of the viewport.

Timing

HookPurpose
useTimeoutsetTimeout with start / stop / reset and isPending.
useIntervalsetInterval with pause / resume; delay = null pauses.

Storage

HookPurpose
useLocalStorage / useSessionStorageSSR-safe useState-shaped hook backed by Web Storage with cross-tab sync.

DOM

HookPurpose
useEventListenerTyped addEventListener for window / document / element / ref.
useDocumentVisibilityReactive document.visibilityState.
useOnlineStatusReactive navigator.onLine boolean.

React-only

Utilities

HookPurpose
useDebounceDebounce a value or callback.
useThrottleThrottle a value or callback.
useMediaQueryReactively match a CSS media query.
useReduceMotionDetect the OS-level reduced-motion preference.

Refs

Last updated on

MIT License © 2026 wire-ui

Hooks / Composables / Primitives – Wire UI