Skip to content

useFocus

jsxhook

useFocus: consume focus state for a focusable element

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

PropTypeDefaultDescription
initialT | undefinedInitial value
persistbooleanfalsePersist to storage
keystringStorage key
#hook#use-focus