useFocus
jsxhook
useFocus: consume focus state for a focusable element
Terminal
$termuijs render use-focus
Installation
$ bunx termuijs add use-focus
Copies the source into src/components/use-focus/ and installs @termuijs/jsx.
Usage
ts
import { useFocus } from '@termuijs/jsx'ts
const { value, set, reset } = useFocus({
initial: undefined,
})API Reference
useFocus
| Prop | Type | Default | Description |
|---|---|---|---|
initial | T | undefined | — | Initial value |
persist | boolean | false | Persist to storage |
key | string | — | Storage key |