Components
← All components

Focus Scope

stimeo--focus

A standalone focus boundary — Tab cycling, initial focus, and restore — for any region.

The stimeo--focus controller exposes the shared FocusTrap as a declarative focus boundary for any region, without building a full modal (the counterpart to Alpine focus / Headless UI's trap). While trap is on, Tab / Shift+Tab cycle within the element, focus moves to the initial target (or the first focusable) when auto, Escape releases it, and on release focus returns to the opener when restore. With inert the rest of the page is made inert (a hard, modal-style isolation); left off it is a soft boundary — Tab still cycles but the background stays reachable. The element carries data-focus-trapped while active and emits activate / deactivate. Behavior only — it does not open/close or render an overlay (pair with Dialog) and does not move DOM (pair with Portal). It reuses the shared focus_trap util, so unlike the modal overlays it never locks page scroll, and it tracks live focusable children (dynamic additions are picked up on the next Tab). Everything is torn down on disconnect (Turbo navigation included) without yanking focus.

running

Activate, then press Tab: focus cycles within the box. Press Escape, Release, or the same button (now Deactivate) to exit.

Keyboard

KeyAction
Tab / Shift+Tab Cycle focus within the scope (wraps at the ends).
Escape Release the trap and restore focus to the opener.