bit Bheadless

FocusTrap

Traps keyboard focus inside a container. Used by Dialog, but also useful standalone.

Implementation: CSS Tailwind

Basic Focus Trap

Toggle the trap. data-state-active: highlights the active container.

Focus is free inside this box.

Slide-over panel

A common pattern: a trap that activates with the panel.

Multiple focusable regions

Only the active trap captures focus.

Region A
Region B
An unhandled error has occurred. Reload 🗙