VisuallyHidden
Hides content visually while keeping it accessible to screen readers.
Import
import { VisuallyHidden } from '@matix/components/visually-hidden';Usage
Use VisuallyHidden when you need to provide additional context to screen readers that is not visible in the UI.
import { Button } from '@matix/components/button';
<Button variant="ghost">
<svg aria-hidden="true" width="16" height="16" viewBox="0 0 24 24" fill="currentColor">
<path d="M19 11H7.83l4.88-4.88c.39-.39.39-1.03 0-1.42-.39-.39-1.02-.39-1.41 0l-6.59 6.59c-.39.39-.39 1.02 0 1.41l6.59 6.59c.39.39 1.02.39 1.41 0 .39-.39.39-1.02 0-1.41L7.83 13H19c.55 0 1-.45 1-1s-.45-1-1-1z" />
</svg>
<VisuallyHidden>Go back</VisuallyHidden>
</Button>;Form Labels
<form>
<label htmlFor="search">
<VisuallyHidden>Search</VisuallyHidden>
</label>
<input id="search" type="search" placeholder="Search…" />
</form>Status Announcements
import { Spinner } from '@matix/components/spinner';
<div role="status" aria-live="polite">
<Spinner />
<VisuallyHidden>Loading results</VisuallyHidden>
</div>;API Reference
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | — | Content to hide visually but keep accessible |
sx | StyleXStyles | — | StyleX style override. Rarely needed. |
All other HTML attributes, such as id and aria-*, go to the <span>. Use an id to make it the target of aria-describedby.
Accessibility
- Applies the standard visually-hidden CSS technique:
position: absolute; clip: rect(0, 0, 0, 0); white-space: nowrap; overflow: hidden; width: 1px; height: 1px. - Content remains in the DOM and is read by screen readers — it is only hidden from visual rendering.
- Do not use
display: noneorvisibility: hiddenwhen you need screen reader access —VisuallyHiddenis the correct pattern. - This technique is preferred over
aria-labelwhen the text is longer or needs to include rich content.
This is an RSC-safe component — it ships no JavaScript to the browser.