Utils
Public helper hooks and low-level utilities for building custom Moraine-based primitives.
Usage#
Import shared helpers from the dedicated subpath:
Top-level styling helpers such as
cn,cva, andextendCNcontinue to be exported frommoraine.
useControllableValue#
Bridge controlled and uncontrolled state with a single accessor/setter pair.
useDisclosureState#
Track open-state metadata for collapsible content, including data-* attrs and measured content height.
useTransitionPresence#
Keep an element mounted until its exit animation or transition finishes.
useSelectableCollectionNavigation#
Add keyboard navigation for tabs, radio groups, listboxes, and similar selectable collections.
createMediaQuery#
Create a reactive boolean accessor from a media query.
useListVirtualizer#
Create a virtualRender adapter for List, Select, or MultiSelect based on @tanstack/virtual-core. Configure row measurement with estimateSize, pass virtualRender to the component, and forward scrollToIndex through Select or MultiSelect’s scrollToItem prop when keyboard navigation needs to reveal an off-screen entry.
useId#
Create a stable accessor for explicit or generated element IDs.
useEventListener and useEventListenerMap#
Attach event listeners with automatic cleanup when the owner scope is disposed.
useLoadingAutoClick#
Wrap async click handlers and derive a loading state automatically while the returned promise is pending.
createContextProvider#
Create a typed Solid context provider and matching consumer hook with optional fallback support.