Focus indicators (typically an outline around a focused element) help keyboard users navigate and identify which element currently has focus, allowing users to interact with elements by pressing Enter instead of using a mouse.
They're also unnecessary when using a mouse, so Frontile only shows them for keyboard input.
Frontile includes a library based on the proposed CSS :focus-visible pseudo-selector. It adds a focus-visible class to focused elements only when keyboard navigation is detected (Tab, Shift + Tab, or arrow keys).
When the mouse is used to focus an element, the class is not added—except for text inputs and textareas, where focus indicators are always helpful.
Try focusing these elements with both keyboard (Tab key) and mouse to see the difference:
import { Button, Input } from 'frontile';
<template>
<div class='space-y-4'>
<Input placeholder='Focus me with Tab or mouse' />
<Button @color='primary'>
Focus me with Tab or mouse
</Button>
</div>
</template>
Notice how the keyboard focus is clearly visible with Tab, but clicking with the mouse doesn't show the focus ring on the button.
Modal, Drawer, Popover, and Dropdown are all built on the shared Overlay primitive, which
manages focus around opening and closing:
@disableFocusTrap={{true}} is passed, the trap doesn't run at
all — in that case Overlay focuses the content itself instead, unless
@preventAutoFocus={{true}} is also passed. (@preventAutoFocus only has an effect when
the trap is disabled; it does nothing when the trap is active.)@focusTrapOptions and can be turned off entirely with @disableFocusTrap={{true}}.@preventFocusRestore={{true}} is passed.Modal and Drawer, aria-modal="true" tracks whether the trap is actually active, so
assistive technology isn't told the page is modal when the trap has been disabled.