:focus-visible
A CSS pseudo-class that matches a focused element only when the browser thinks a focus indicator is needed, typically for keyboard use.
In more detail
Styling :focus-visible instead of :focus shows a clear focus ring to keyboard users without drawing rings after every mouse click. Rings must meet contrast requirements and stay visible in forced colors mode.
Related terms
- keyboard focus — The state of being the one element on the page that receives keyboard input, usually shown with an outline.
- high-contrast theme — A theme with maximum difference between text, borders and backgrounds for people with low vision.
Taught in
- Actionable Form Primitives: Buttons, Switches & Inputs — Design Systems & Component Engineering
- Focus Management: Trapping, Restoration & Focus Rings — Design Systems & Component Engineering