Layout & primitives
VisuallyHidden
Free0.2 KB gzippedHides content visually while keeping it available to screen readers.
Accessibility: WCAG 2.2 AA · No A or AA violations in light or dark mode · No keyboard interaction of its own · Full report
Import
import { VisuallyHidden } from "@vjdesigns/vjdesigns-ui";
Importing only VisuallyHidden adds about 0.2 KB of minified, gzipped JavaScript to your app (React not included). The stylesheet is shared by every component and loaded once: 75.1 KB gzipped.
Examples
Extra context
Hides content visually but keeps it for screen readers. Here, sighted users see a short price while screen reader users also hear what it covers.
$49 per month, billed yearly
import { Flex, Text, VisuallyHidden } from "@vjdesigns/vjdesigns-ui";
export function ExtraContext() {
return (
<Flex gap={4} align="baseline">
<Text size="2xl" weight="bold">
$49
<VisuallyHidden> per month, billed yearly</VisuallyHidden>
</Text>
<Text tone="muted" aria-hidden="true">
/mo
</Text>
</Flex>
);
}
Clarify repeated links
Add context a visual layout makes obvious but a screen reader can't infer.
import { Flex, RatingDisplay, VisuallyHidden } from "@vjdesigns/vjdesigns-ui";
export function ClarifyRepeatedLinks() {
return (
<Flex gap={4} align="center">
<RatingDisplay value={4.5} size="sm" />
<a href="#example-clarify-repeated-links">
Read reviews<VisuallyHidden> for the Trail Runner 2</VisuallyHidden>
</a>
</Flex>
);
}
Accessibility
Add the context that sighted users get from layout. Here the screen reader hears "Price: $24 per month", while the screen shows "$24/mo".
Price: $24 per month
import { Text, VisuallyHidden } from "@vjdesigns/vjdesigns-ui";
export function Accessibility() {
return (
<Text size="xl" weight="bold">
<VisuallyHidden>Price: </VisuallyHidden>
<span aria-hidden="true">$24/mo</span>
<VisuallyHidden>$24 per month</VisuallyHidden>
</Text>
);
}
Translated
Prefer visually hidden text to aria-label on multilingual sites: browser page translators translate hidden text along with the page, but often skip aria-label attributes.
Lien avec un texte masqué traduisible
import {
Flex,
Text,
VisuallyHidden,
LocaleProvider,
} from "@vjdesigns/vjdesigns-ui";
import fr from "@vjdesigns/vjdesigns-ui/locales/fr";
export function Translated() {
return (
<LocaleProvider locale="fr" messages={fr}>
<Flex gap={2} align="center">
<a href="#example-translated">
<span aria-hidden="true">→</span>
<VisuallyHidden>Lire la suite de l'article</VisuallyHidden>
</a>
<Text size="sm" tone="muted">
Lien avec un texte masqué traduisible
</Text>
</Flex>
</LocaleProvider>
);
}
Right to left
The first example again, inside a right-to-left LocaleProvider (Arabic). Layout, spacing and arrow icons mirror, and the components' built-in text is translated. The example's own text stays in English.
Extra context
$49 per month, billed yearly
import { LocaleProvider } from "@vjdesigns/vjdesigns-ui";
import ar from "@vjdesigns/vjdesigns-ui/locales/ar";
// ExtraContext is the "Extra context" example above.
<LocaleProvider locale="ar" messages={ar}>
<ExtraContext />
</LocaleProvider>
API reference
VisuallyHidden
Also accepts standard HTML attributes, plus className, style and ref.
See what changed in each version in the Changelog.
Accessibility report
VisuallyHidden targets WCAG 2.2 AA. Below: a live axe-core audit of this page's examples, Lighthouse scores for the page in both modes, the accessibility behavior built into the component, and the checks only a person can do.
axe-core audit (live)
Checking the examples above…
Lighthouse audit
Light mode
Score 10035 passed · 0 failed · 30 not applicable · 10 to check by hand
Dark mode
Score 10035 passed · 0 failed · 30 not applicable · 10 to check by hand
Lighthouse 13.5.0 audits the whole docs page (header and sidebar included), not just the examples, in English. Last run 11/27/2026. Some failed audits carry no weight in the score, so a page can score 100 and still list one.
Built-in behavior
Keyboard
Not focusable, so there's no keyboard interaction of its own.
Roles and states
| Element | Role | States and properties |
|---|---|---|
<span> | none (generic) | Hidden visually, still read by screen readers |
Manual checks
Automated tools find roughly a third of accessibility issues. Test these in your app, with your content.
| Check | What to test | WCAG 2.2 |
|---|---|---|
| Keyboard | Every action works with Tab, Shift+Tab, Enter, Space and the arrow keys, and focus never gets stuck. | 2.1.1 (A), 2.1.2 (A) |
| Focus | Focus moves in a logical order, is always visible, and isn't hidden behind sticky headers. | 2.4.3 (A), 2.4.7 (AA), 2.4.11 (AA), 2.4.13 (AAA) |
| Screen readers | Names, roles and states are announced correctly, and status changes are announced without moving focus. | 1.3.1 (A), 4.1.2 (A), 4.1.3 (AA) |
| Color | Meaning never depends on color alone; your own colors meet contrast in both modes. | 1.4.1 (A), 1.4.3 (AA), 1.4.11 (AA), 1.4.6 (AAA) |
| Zoom and reflow | At 200% text size and at 320px wide (400% zoom), nothing is cut off and no sideways scrolling is needed. | 1.4.4 (AA), 1.4.10 (AA), 1.4.12 (AA) |
| Pointer targets | Click and tap targets are at least 24×24px (44×44px for AAA), or spaced so they don't overlap. | 2.5.8 (AA), 2.5.5 (AAA) |
| Motion | Animations respect the reduced-motion setting. | 2.3.3 (AAA) |