Skip to content
Okaapiأوكابي
Framework for the code
Theme
Okaapi on GitHub

Chapter 02 Foundations

Focus

One ring marks the keyboard on every control, 3:1 in both themes, for the keyboard only.

Tokens

Outside the edge on controls, inside it on list items.

TokenValueTailwindForSample
--ui-focus#0047cc · #8fb4ffoutline-focusRing colour, light and dark. 3:1 on the page.
--ui-focus-width3pxfocus-visible:focus-ringRing thickness.
--ui-focus-offset2pxfocus-visible:focus-ring-insetGap from the edge. Inset rings use minus the width.

Try the ring

Both placements follow the tokens; the inset one uses minus the width.

3px2px

Outside and inset

A button gets the ring outside; a menu item gets it inside, so its neighbours never cover it.

Angular
<!-- The tokens: --ui-focus-width: 3px; --ui-focus-offset: 2px -->
<button class="ui-button ui-button--primary">Save</button>
<a class="rounded-ui px-3 py-2 focus-visible:focus-ring" href="/orders">Orders</a>
<li class="px-3 focus-visible:focus-ring-inset" tabindex="-1">Invoices</li>

Rules

  • Dialogs take focus on open and hand it back on close.
  • Lists keep focus on the control and ring the active option.
  • A sticky header needs scroll-padding-block-start so it never hides focus.