Skip to content

useFocusTrap

jsxhook

useFocusTrap: cycle Tab / Shift+Tab focus through a fixed list of IDs

Installation

$ bunx termuijs add use-focus-trap

Copies the source into src/components/use-focus-trap/ and installs @termuijs/jsx.

Usage

ts
import { useFocusTrap } from '@termuijs/jsx'
ts
const { value, set, reset } = useFocusTrap({
  initial: undefined,
})

API Reference

useFocusTrap

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