Skip to content
BigBang

Popular

    ↑↓Navigate↵OpenEscClose
    TR

    Components

    VisuallyHidden

    Hides content visually and keeps it available to screen readers.

    Storybook
    Storybook
    Source
    Source

    VisuallyHidden is for text meant for screen readers only: the name of an icon-only button, the caption of a table with no visible title, or a skip link.

    • When a visible label exists: If the screen already shows the text, do not add a hidden copy; it is read twice.
    • To hide content: For content nobody should see, use hidden or conditional rendering; VisuallyHidden keeps the content available to screen readers.
    • For long descriptions: Keep hidden text short; make a long description visible.

    VisuallyHidden has one part: a <span> (or the element you give with render).

    1. Root: the sr-only class; clipped to a 1 px box, absolutely positioned, and kept in the accessibility tree.
    • By default the content is hidden visually and available to screen readers.
    • With focusable the content becomes visible while it, or a link inside it, has focus (focus:not-sr-only, focus-within:not-sr-only).
    • render draws elements such as <caption> or <a>.
    • It accepts no inline style; there are no className or style props.
    DoThe hidden text says what the button does.
    Don'tNo name: a screen reader says only “button”.

    Use focusable for a skip link; otherwise a keyboard user cannot see where focus is.

    • Write it short: Close, Open menu, Skip to content.
    • Use the same language as the visible text.
    • Say what the button does, not the name of the icon.
    • Text: Visible text that everyone reads.
    • Icon: The decorative icon in an icon-only button.
    • Button: The container of an icon-only button.