loading code fetching the highlighted snippet
Tab through the three elements below — whileFocus animates them while they hold focus and reverses on blur. Works on natively focusable elements (button, input) and anything with tabindex.
whileFocus fires for both keyboard focus (Tab) and click focus. Same
animation shape as whileHover — pass keyframes (or a variant key) and the
value lasts as long as the element holds focus.tabindex="0" to opt into the focus chain — any element can
be focusable, not just buttons and inputs. Useful for custom UI surfaces.onFocusStart / onFocusEnd callbacks with your own state
if you need to react beyond the visual animation (e.g. announce to screen readers, fetch
preview data).Tab through or click the elements below to see focus animations: