← Back to Docs
Recipe

Keyboard navigation design

A systematic approach to building fully keyboard-accessible interfaces without sacrificing visual polish.

Focus ring strategy

Use focus-visible:ring-2 with a violet offset. Never strip outlines globally — scope suppression to pointer-driven interactions via :focus:not(:focus-visible).

Tab order

Assign tabIndex values sparingly. Rely on DOM order for natural flow. Reserve tabIndex=0 for custom widgets and tabIndex=-1 for programmatic focus management in modals and drawers.

Arrow-key roving

For listboxes, tabs, and grids, implement a roving tabindex pattern. One element holds tabIndex=0 while siblings use tabIndex=-1. Arrow keys shift focus and update the index.

Skip links

Place a visually hidden “Skip to content” link as the first focusable element. On focus, surface it with a fixed top-center banner styled in violet.

Escape and Enter

Bind Escape to dismiss overlays and return focus to the trigger element. Enter activates the currently focused interactive element.

Tip: Test every view with a keyboard only. If you cannot reach or operate a control, the recipe is incomplete.