Overview
Visually Hidden hides content visually while keeping it accessible to screen readers. This is useful for providing additional context or labels that don’t need to be visible but should be announced by assistive technologies.Features
- Hides content visually using CSS
- Content remains accessible to screen readers
- Content remains in the document flow
Installation
Anatomy
API Reference
Root
Hides content visually while keeping it accessible to screen readers.React.ReactNode
The content to be visually hidden.
Examples
Form Label
Skip to Content Link
Icon Button Label
Using VISUALLY_HIDDEN_STYLES
The component also exports the CSS styles used to visually hide content, which you can use directly:How It Works
The component uses a combination of CSS properties to hide content visually:position: absolute- Removes from normal document flowwidth: 1pxandheight: 1px- Makes element nearly invisiblepadding: 0andmargin: -1px- Minimizes spaceoverflow: hidden- Hides any overflowclip: rect(0, 0, 0, 0)- Clips the elementwhiteSpace: nowrap- Prevents wrapping
When to Use
Use Visually Hidden when you need to:- Provide additional context for screen readers
- Add labels to form inputs that don’t need to be visible
- Include descriptive text for icon-only buttons
- Create skip links for keyboard navigation
- Provide status messages that are announced but not shown