10
documented hooks, exported from @swirski/ui and installable through the registry CLI.
Swirski hooks are small client-side utilities for the behavior that shows up across components: disclosure state, controlled state, outside clicks, keyboard escape, clipboard, storage and responsive preferences.
documented hooks, exported from @swirski/ui and installable through the registry CLI.
Hooks can be imported from the package or copied into an app with the registry CLI. Copied hooks follow dependency metadata, so `useDisclosure` also brings `useControllableState`.
import { useDisclosure, useClipboard } from "@swirski/ui";swirski add use-disclosure use-clipboardThese hooks are deliberately small. They cover the behavioral patterns that repeat across Swirski components and app screens.
| Hook | Use it for |
|---|---|
| useDisclosure | Dialogs, drawers, popovers, accordions and custom show/hide UI. |
| useControllableState | Components that support both controlled and uncontrolled props. |
| useClickOutside | Menus, custom selects, floating panels and dismissible surfaces. |
| useClipboard | Copy buttons, registry commands, install snippets and code blocks. |
| useIsPathnameActive | Navigation links, sidebars, breadcrumbs and active route styling. |
`useDisclosure` is the everyday hook for open/close UI. It returns the current boolean state and a small handler object.
Open hook docsconst [opened, handlers] = useDisclosure(false);
return (
<>
<Button onClick={handlers.open}>Open</Button>
<Button onClick={handlers.close}>Close</Button>
<Button onClick={handlers.toggle}>Toggle</Button>
</>
);Boolean open/close/toggle state for dialogs, drawers, popovers and custom disclosure UI.
A small helper for components that support both controlled and uncontrolled state.
Runs a callback when pointer events happen outside a referenced element.
Runs a callback when Escape is pressed.
Checks whether a pathname matches the current URL path, including nested routes.
Persists React state in localStorage with serializer hooks.
Tracks a CSS media query in React state.
Reads the user preference for reduced motion.
Copies text to the clipboard and tracks copied/error state.
Returns the document body once the app has mounted so portal components can render safely.