VisuallyHidden
<VisuallyHidden>
is a component that visually hides its children while keeping them accessible to screen readers and assistive technologies.
This is especially useful when you want to preserve the native behavior and semantics of elements like checkboxes or radio buttons, but visually replace them with custom-styled components.
Anatomy
The <VisuallyHidden>
contains of a simple <div>
element, where you can add children.
Appearance
<label style={{ position: 'relative' }}>
<VisuallyHidden>
<input type="checkbox" />
</VisuallyHidden>
<span>Subscribe to our newsletter</span>
</label>
Usage
You should use <VisuallyHidden>
when you want to make information available to screen reader users without displaying it visually on the screen.
This is especially useful for accessibility purposes—such as labeling icon-only buttons, adding helpful instructions to form fields, or including context like headings or descriptions that assist navigation for screen reader users. By doing so, you ensure your interface remains clean and visually simple for sighted users while still being fully accessible and understandable for those relying on assistive technologies.
Use VisuallyHidden
to add meaningful accessibility enhancements.
Don’t use <VisuallyHidden>
to compensate for poorly labeled or structured elements—fix the design instead.
Supplemental context
Sometimes you need to include additional context that isn’t necessary to show visually but is important for users who rely on screen readers. For example, this could be clarifying instructions, status updates, or descriptions that help non-visual users understand what’s happening on the page.
Using a visually hidden element ensures that this information is announced by assistive technologies without disrupting the visual layout or overwhelming sighted users with extra text.
<VisuallyHidden>All fields marked with * are required.</VisuallyHidden>
Props
aria-activedescendant?
string;
aria-atomic?
Booleanish;
aria-autocomplete?
"list" | "none" | "inline" | "both";
aria-braillelabel?
string;
aria-brailleroledescription?
string;
aria-busy?
Booleanish;
aria-checked?
boolean | "true" | "false" | "mixed";
aria-colcount?
number;
aria-colindex?
number;
aria-colindextext?
string;
aria-colspan?
number;
aria-controls?
string;
aria-current?
boolean | "true" | "false" | "page" | "step" | "location" | "date" | "time";
aria-describedby?
string;
aria-description?
string;
aria-details?
string;
aria-disabled?
Booleanish;
aria-dropeffect?
"link" | "none" | "copy" | "execute" | "move" | "popup";
aria-errormessage?
string;
aria-expanded?
Booleanish;
aria-flowto?
string;
aria-grabbed?
Booleanish;
aria-haspopup?
boolean | "dialog" | "grid" | "listbox" | "menu" | "tree" | "true" | "false";
aria-hidden?
Booleanish;
aria-invalid?
boolean | "true" | "false" | "grammar" | "spelling";
aria-keyshortcuts?
string;
aria-label?
string;
aria-labelledby?
string;
aria-level?
number;
aria-live?
"off" | "assertive" | "polite";
aria-modal?
Booleanish;
aria-multiline?
Booleanish;
aria-multiselectable?
Booleanish;
aria-orientation?
"horizontal" | "vertical";
aria-owns?
string;
aria-placeholder?
string;
aria-posinset?
number;
aria-pressed?
boolean | "true" | "false" | "mixed";
aria-readonly?
Booleanish;
aria-relevant?
"additions" |
"additions removals" |
"additions text" |
"all" |
"removals" |
"removals additions" |
"removals text" |
"text" |
"text additions" |
"text removals";
aria-required?
Booleanish;
aria-roledescription?
string;
aria-rowcount?
number;
aria-rowindex?
number;
aria-rowindextext?
string;
aria-rowspan?
number;
aria-selected?
Booleanish;
aria-setsize?
number;
aria-sort?
"none" | "ascending" | "descending" | "other";
aria-valuemax?
number;
aria-valuemin?
number;
aria-valuenow?
number;
aria-valuetext?
string;
children?
ReactNode;
className?
string;
dangerouslySetInnerHTML?
{
__html: string | TrustedHTML;
}
elementType?
string | JSXElementConstructor<any>;
'div'
id?
string;
isFocusable?
boolean;
onAbort?
ReactEventHandler<FocusableElement>;
onAbortCapture?
ReactEventHandler<FocusableElement>;
onAnimationEnd?
AnimationEventHandler<FocusableElement>;
onAnimationEndCapture?
AnimationEventHandler<FocusableElement>;
onAnimationIteration?
AnimationEventHandler<FocusableElement>;
onAnimationIterationCapture?
AnimationEventHandler<FocusableElement>;
onAnimationStart?
AnimationEventHandler<FocusableElement>;
onAnimationStartCapture?
AnimationEventHandler<FocusableElement>;
onAuxClick?
MouseEventHandler<FocusableElement>;
onAuxClickCapture?
MouseEventHandler<FocusableElement>;
onBeforeInput?
InputEventHandler<FocusableElement>;
onBeforeInputCapture?
FormEventHandler<FocusableElement>;
onBeforeToggle?
ToggleEventHandler<FocusableElement>;
onBlur?
FocusEventHandler<FocusableElement>;
onBlurCapture?
FocusEventHandler<FocusableElement>;
onCanPlay?
ReactEventHandler<FocusableElement>;
onCanPlayCapture?
ReactEventHandler<FocusableElement>;
onCanPlayThrough?
ReactEventHandler<FocusableElement>;
onCanPlayThroughCapture?
ReactEventHandler<FocusableElement>;
onChange?
FormEventHandler<FocusableElement>;
onChangeCapture?
FormEventHandler<FocusableElement>;
onClick?
MouseEventHandler<FocusableElement>;
onClickCapture?
MouseEventHandler<FocusableElement>;
onCompositionEnd?
CompositionEventHandler<FocusableElement>;
onCompositionEndCapture?
CompositionEventHandler<FocusableElement>;
onCompositionStart?
CompositionEventHandler<FocusableElement>;
onCompositionStartCapture?
CompositionEventHandler<FocusableElement>;
onCompositionUpdate?
CompositionEventHandler<FocusableElement>;
onCompositionUpdateCapture?
CompositionEventHandler<FocusableElement>;
onContextMenu?
MouseEventHandler<FocusableElement>;
onContextMenuCapture?
MouseEventHandler<FocusableElement>;
onCopy?
ClipboardEventHandler<FocusableElement>;
onCopyCapture?
ClipboardEventHandler<FocusableElement>;
onCut?
ClipboardEventHandler<FocusableElement>;
onCutCapture?
ClipboardEventHandler<FocusableElement>;
onDoubleClick?
MouseEventHandler<FocusableElement>;
onDoubleClickCapture?
MouseEventHandler<FocusableElement>;
onDrag?
DragEventHandler<FocusableElement>;
onDragCapture?
DragEventHandler<FocusableElement>;
onDragEnd?
DragEventHandler<FocusableElement>;
onDragEndCapture?
DragEventHandler<FocusableElement>;
onDragEnter?
DragEventHandler<FocusableElement>;
onDragEnterCapture?
DragEventHandler<FocusableElement>;
onDragExit?
DragEventHandler<FocusableElement>;
onDragExitCapture?
DragEventHandler<FocusableElement>;
onDragLeave?
DragEventHandler<FocusableElement>;
onDragLeaveCapture?
DragEventHandler<FocusableElement>;
onDragOver?
DragEventHandler<FocusableElement>;
onDragOverCapture?
DragEventHandler<FocusableElement>;
onDragStart?
DragEventHandler<FocusableElement>;
onDragStartCapture?
DragEventHandler<FocusableElement>;
onDrop?
DragEventHandler<FocusableElement>;
onDropCapture?
DragEventHandler<FocusableElement>;
onDurationChange?
ReactEventHandler<FocusableElement>;
onDurationChangeCapture?
ReactEventHandler<FocusableElement>;
onEmptied?
ReactEventHandler<FocusableElement>;
onEmptiedCapture?
ReactEventHandler<FocusableElement>;
onEncrypted?
ReactEventHandler<FocusableElement>;
onEncryptedCapture?
ReactEventHandler<FocusableElement>;
onEnded?
ReactEventHandler<FocusableElement>;
onEndedCapture?
ReactEventHandler<FocusableElement>;
onError?
ReactEventHandler<FocusableElement>;
onErrorCapture?
ReactEventHandler<FocusableElement>;
onFocus?
FocusEventHandler<FocusableElement>;
onFocusCapture?
FocusEventHandler<FocusableElement>;
onGotPointerCapture?
PointerEventHandler<FocusableElement>;
onGotPointerCaptureCapture?
PointerEventHandler<FocusableElement>;
onInput?
FormEventHandler<FocusableElement>;
onInputCapture?
FormEventHandler<FocusableElement>;
onInvalid?
FormEventHandler<FocusableElement>;
onInvalidCapture?
FormEventHandler<FocusableElement>;
onKeyDown?
KeyboardEventHandler<FocusableElement>;
onKeyDownCapture?
KeyboardEventHandler<FocusableElement>;
onKeyPress?
KeyboardEventHandler<FocusableElement>;
onKeyUp
or onKeyDown
insteadonKeyPressCapture?
KeyboardEventHandler<FocusableElement>;
onKeyUpCapture
or onKeyDownCapture
insteadonKeyUp?
KeyboardEventHandler<FocusableElement>;
onKeyUpCapture?
KeyboardEventHandler<FocusableElement>;
onLoad?
ReactEventHandler<FocusableElement>;
onLoadCapture?
ReactEventHandler<FocusableElement>;
onLoadStart?
ReactEventHandler<FocusableElement>;
onLoadStartCapture?
ReactEventHandler<FocusableElement>;
onLoadedData?
ReactEventHandler<FocusableElement>;
onLoadedDataCapture?
ReactEventHandler<FocusableElement>;
onLoadedMetadata?
ReactEventHandler<FocusableElement>;
onLoadedMetadataCapture?
ReactEventHandler<FocusableElement>;
onLostPointerCapture?
PointerEventHandler<FocusableElement>;
onLostPointerCaptureCapture?
PointerEventHandler<FocusableElement>;
onMouseDown?
MouseEventHandler<FocusableElement>;
onMouseDownCapture?
MouseEventHandler<FocusableElement>;
onMouseEnter?
MouseEventHandler<FocusableElement>;
onMouseLeave?
MouseEventHandler<FocusableElement>;
onMouseMove?
MouseEventHandler<FocusableElement>;
onMouseMoveCapture?
MouseEventHandler<FocusableElement>;
onMouseOut?
MouseEventHandler<FocusableElement>;
onMouseOutCapture?
MouseEventHandler<FocusableElement>;
onMouseOver?
MouseEventHandler<FocusableElement>;
onMouseOverCapture?
MouseEventHandler<FocusableElement>;
onMouseUp?
MouseEventHandler<FocusableElement>;
onMouseUpCapture?
MouseEventHandler<FocusableElement>;
onPaste?
ClipboardEventHandler<FocusableElement>;
onPasteCapture?
ClipboardEventHandler<FocusableElement>;
onPause?
ReactEventHandler<FocusableElement>;
onPauseCapture?
ReactEventHandler<FocusableElement>;
onPlay?
ReactEventHandler<FocusableElement>;
onPlayCapture?
ReactEventHandler<FocusableElement>;
onPlaying?
ReactEventHandler<FocusableElement>;
onPlayingCapture?
ReactEventHandler<FocusableElement>;
onPointerCancel?
PointerEventHandler<FocusableElement>;
onPointerCancelCapture?
PointerEventHandler<FocusableElement>;
onPointerDown?
PointerEventHandler<FocusableElement>;
onPointerDownCapture?
PointerEventHandler<FocusableElement>;
onPointerEnter?
PointerEventHandler<FocusableElement>;
onPointerLeave?
PointerEventHandler<FocusableElement>;
onPointerMove?
PointerEventHandler<FocusableElement>;
onPointerMoveCapture?
PointerEventHandler<FocusableElement>;
onPointerOut?
PointerEventHandler<FocusableElement>;
onPointerOutCapture?
PointerEventHandler<FocusableElement>;
onPointerOver?
PointerEventHandler<FocusableElement>;
onPointerOverCapture?
PointerEventHandler<FocusableElement>;
onPointerUp?
PointerEventHandler<FocusableElement>;
onPointerUpCapture?
PointerEventHandler<FocusableElement>;
onProgress?
ReactEventHandler<FocusableElement>;
onProgressCapture?
ReactEventHandler<FocusableElement>;
onRateChange?
ReactEventHandler<FocusableElement>;
onRateChangeCapture?
ReactEventHandler<FocusableElement>;
onReset?
FormEventHandler<FocusableElement>;
onResetCapture?
FormEventHandler<FocusableElement>;
onScroll?
UIEventHandler<FocusableElement>;
onScrollCapture?
UIEventHandler<FocusableElement>;
onScrollEnd?
UIEventHandler<FocusableElement>;
onScrollEndCapture?
UIEventHandler<FocusableElement>;
onSeeked?
ReactEventHandler<FocusableElement>;
onSeekedCapture?
ReactEventHandler<FocusableElement>;
onSeeking?
ReactEventHandler<FocusableElement>;
onSeekingCapture?
ReactEventHandler<FocusableElement>;
onSelect?
ReactEventHandler<FocusableElement>;
onSelectCapture?
ReactEventHandler<FocusableElement>;
onStalled?
ReactEventHandler<FocusableElement>;
onStalledCapture?
ReactEventHandler<FocusableElement>;
onSubmit?
FormEventHandler<FocusableElement>;
onSubmitCapture?
FormEventHandler<FocusableElement>;
onSuspend?
ReactEventHandler<FocusableElement>;
onSuspendCapture?
ReactEventHandler<FocusableElement>;
onTimeUpdate?
ReactEventHandler<FocusableElement>;
onTimeUpdateCapture?
ReactEventHandler<FocusableElement>;
onToggle?
ToggleEventHandler<FocusableElement>;
onTouchCancel?
TouchEventHandler<FocusableElement>;
onTouchCancelCapture?
TouchEventHandler<FocusableElement>;
onTouchEnd?
TouchEventHandler<FocusableElement>;
onTouchEndCapture?
TouchEventHandler<FocusableElement>;
onTouchMove?
TouchEventHandler<FocusableElement>;
onTouchMoveCapture?
TouchEventHandler<FocusableElement>;
onTouchStart?
TouchEventHandler<FocusableElement>;
onTouchStartCapture?
TouchEventHandler<FocusableElement>;
onTransitionCancel?
TransitionEventHandler<FocusableElement>;
onTransitionCancelCapture?
TransitionEventHandler<FocusableElement>;
onTransitionEnd?
TransitionEventHandler<FocusableElement>;
onTransitionEndCapture?
TransitionEventHandler<FocusableElement>;
onTransitionRun?
TransitionEventHandler<FocusableElement>;
onTransitionRunCapture?
TransitionEventHandler<FocusableElement>;
onTransitionStart?
TransitionEventHandler<FocusableElement>;
onTransitionStartCapture?
TransitionEventHandler<FocusableElement>;
onVolumeChange?
ReactEventHandler<FocusableElement>;
onVolumeChangeCapture?
ReactEventHandler<FocusableElement>;
onWaiting?
ReactEventHandler<FocusableElement>;
onWaitingCapture?
ReactEventHandler<FocusableElement>;
onWheel?
WheelEventHandler<FocusableElement>;
onWheelCapture?
WheelEventHandler<FocusableElement>;
role?
AriaRole;
tabIndex?
number;