Visually Hidden

Visually Hidden

Utilities
Accessibility

Hides content visually while keeping it accessible to screen readers and other assistive technologies. Essential for providing context to non-visual users.

Preview

Content that's visually hidden but accessible

The buttons below have visually hidden text. Use a screen reader or inspect the DOM to see the hidden content.

Skip Link

Accessible skip link for keyboard navigation

Press Tab to reveal the skip link (it becomes visible on focus).

Skip to main content

Navigation area - the skip link appears when focused via keyboard.

Hidden Form Labels

Labels that are redundant visually but needed for accessibility

Screen readers will announce "Email Address, required"

Loading Announcements

Announce loading states to screen readers

Screen readers will announce "Saving, please wait..."

Table Context

Provide context for data tables

Quarterly sales data for 2024. Table has 4 rows and 3 columns: Quarter, Revenue, and Growth.
QuarterRevenueGrowth
Q1$1.2M+12%
Q2$1.5M+25%

Props

VisuallyHidden API reference

PropTypeDefaultDescription
children*React.ReactNode—Content to hide visually
classNamestring—Additional CSS classes

Utility Styles

Use styles directly when component isn't suitable

import { visuallyHiddenStyles } from '@/components/ui/visually-hidden'
// Use as inline styles
<span style={visuallyHiddenStyles}>
Hidden content
</span>
// The styles object contains:
{
position: 'absolute',
border: 0,
width: 1,
height: 1,
padding: 0,
margin: -1,
overflow: 'hidden',
clip: 'rect(0, 0, 0, 0)',
whiteSpace: 'nowrap',
wordWrap: 'normal',
}

Usage

Import and implementation examples

import { VisuallyHidden } from '@/components/ui/visually-hidden'
// Icon button with hidden label
<button>
<TrashIcon />
<VisuallyHidden>Delete item</VisuallyHidden>
</button>
// Required field indicator
<label>
Email
<VisuallyHidden> (required)</VisuallyHidden>
</label>
// Loading announcement
<span role="status">
<VisuallyHidden>Loading complete</VisuallyHidden>
</span>
// Table caption
<table>
<caption>
<VisuallyHidden>
Sales data for Q1-Q4 2024
</VisuallyHidden>
</caption>
...
</table>

Features

Built-in functionality

  • Screen reader accessible: Content announced by assistive tech
  • Visually hidden: Not visible to sighted users
  • Preserves layout: No visual space taken in DOM
  • Utility export: Styles available for edge cases
  • Radix primitive: Proven accessibility pattern

Accessibility

Accessibility details

ARIA Attributes

Content remains in DOM and accessible treeCan include role attributes for live regionsSupports all standard HTML attributes

Keyboard Navigation

KeyAction
N/AHidden content is not focusable unless it contains focusable elements

Notes

  • Use for meaningful content that sighted users can infer from context
  • Avoid hiding important visual information
  • Test with screen reader to verify announcements
  • Consider using aria-label or aria-labelledby for simpler cases