---
title: Hooks
description: Headless interaction primitives and reactive utilities exported
  from moraine/utils.
package: moraine
version: 0.11.0
repository: https://github.com/subframe7536/moraine
---

# Hooks

> Headless interaction primitives and reactive utilities exported from moraine/utils.

Moraine exports its headless interaction primitives and reactive utilities from the `moraine/utils` entry point. These hooks back Moraine's own components. Use them to build custom controls.

## Import

Import hooks from the `moraine/utils` subpath:

```tsx
import {
  createBaseSelectSearchInput,
  createControllableValue,
  createCopy,
  createDisclosureState,
  createEventListener,
  createEventListenerMap,
  createId,
  createMediaQuery,
  createSelectableCollectionNavigation,
  createSlider,
  createTransitionPresence,
} from 'moraine/utils'
```

The styling helpers `cn`, `createCn`, and `useCn` are exported from `moraine`, not `moraine/utils`. See [Class Merging](https://moraine.subf.dev/docs/class-merging.md).

## Headless Hooks

- [createBaseSelectSearchInput](https://moraine.subf.dev/hooks/create-base-select-search-input.md): Bind a custom text input to BaseSelect with accessible keyboard and IME behavior.
- [createControllableValue](https://moraine.subf.dev/hooks/create-controllable-value.md): Bridge controlled and uncontrolled component state with a single reactive accessor and setter pair.
- [createCopy](https://moraine.subf.dev/hooks/create-copy.md): Reactive clipboard primitive with duration-based status, ClipboardItem support, and an execCommand fallback.
- [createDisclosureState](https://moraine.subf.dev/hooks/create-disclosure-state.md): Track open state, content height, and data-attribute getters for collapsible panels.
- [createEventListener](https://moraine.subf.dev/hooks/create-event-listener.md): Attach typed DOM event listeners that clean up automatically when the Solid owner scope disposes.
- [createId](https://moraine.subf.dev/hooks/create-id.md): Generate unique, SSR-safe identifiers for accessibility relationships and form controls.
- [createMediaQuery](https://moraine.subf.dev/hooks/create-media-query.md): Create a reactive boolean accessor tracking the match status of any CSS media query.
- [createSelectableCollectionNavigation](https://moraine.subf.dev/hooks/create-selectable-collection-navigation.md): Add accessible keyboard navigation (arrow keys, Home/End, RTL) for tabs, radio groups, and listboxes.
- [createSlider](https://moraine.subf.dev/hooks/create-slider.md): Headless pointer dragging, keyboard stepping, step snapping, and thumb styles for single or multi-thumb range sliders.
- [createTransitionPresence](https://moraine.subf.dev/hooks/create-transition-presence.md): Keep an element mounted until its CSS exit animation finishes.

