Components
Focus ring
The 2.5 Accent :focus-visible ring 2 outside the element, following its radius, and the selection ring.
Contract
Contract: components/focus-ring.yaml. States are drawn live by transit.js.
Loading the contract…
Variants
One ring; no variants. The global :focus-visible rule draws it 2 outside the element, following its radius. Inside a clipped container (the map control stack, a scrolling segmented control) it is drawn inside instead. Nothing else exists.
/* Do: the global rule draws it; a clipped container draws it inside */
:where(:focus-visible){outline:var(--size-focus-ring-width) solid var(--focus-color,var(--focus));outline-offset:var(--size-focus-ring-offset)}
.ct-map-controls>button:focus-visible{outline-offset:calc(var(--size-focus-ring-width) * -1)}
/* Don't: remove it without drawing it elsewhere */
.my-control:focus{outline:none}
Usage
Do
- Let the global
:focus-visiblerule draw the ring. - Draw the ring on a wrapper (
:focus-within) or an indicator when the element itself can't show it.
Don't
- Don't set
outline: nonewithout drawing the ring elsewhere. - Don't draw a square ring on a round control.
Accessibility
- Keyboard focus is always visible: a 2.5 Accent ring 2 outside the element, following its radius.