AutoFocus

Primitive #22

🔍 Problem it solves

When a dialog or popover opens, focus should automatically move to the first focusable element (or a specific element, like a search input). Manually calling `.focus()` on the right element is fragile, especially with dynamic content.

✅ Solution

autoFocus(container, options) automatically focuses the first focusable element, the last focusable element, or an element specified by selector/index when the container becomes active.

🧩 Used by components

Dialog, Modal, Drawer, Popover, CommandPalette, SearchBox

🎮 Interactive demo