Skip to main content
On this page

Visually Hidden

VisuallyHidden renders content that is visible to screen readers but hidden from sighted users.

When to use​

  • To add screen-reader-only context to an interactive element that has no visible text label, such as an icon-only button
  • To disambiguate repeated link or button labels, such as multiple "Find out more" links on the same page, by appending specific context
  • To announce a currency denomination or unit alongside a numeric input, where the context is visually clear from the UI but absent from the input's accessible label
  • To provide off-screen context that would be redundant or noisy if shown visually, but is necessary for screen reader users to understand the structure

When not to use​

  • To hide content from all users - VisuallyHidden is not a general hide utility. Content that sighted users should not see should be conditionally rendered or removed from the DOM, not hidden with this component.
  • To hide content that visual users also need - if the information is important, show it visually. Visually hidden content creates an inconsistency between visual and screen reader experiences.
  • As a substitute for a proper accessible name - if a button or input can have a visible label, give it one. Visually hidden labels are a fallback, not a first choice.
  • For decorative content - decorative images and icons should use aria-hidden="true", not VisuallyHidden.

Anatomy​

  1. VisuallyHidden (a span element positioned absolutely at 1x1px, with overflow hidden and white-space nowrap, so it does not affect page layout but remains in the accessibility tree)

Basic usage​

Add visually hidden text inside an interactive element to supplement its label.

Loading...
Edit live code
<P>
  <TextLink href="#">
    Find out more<VisuallyHidden> about tracking carbon</VisuallyHidden>
  </TextLink>
</P>

Variants and features​

When the same link text appears multiple times on a page, screen reader users navigating by links hear a list of identical items with no useful distinction. Add visually hidden text to make each link unique.

Always include a leading space before the visually hidden text to prevent screen readers from concatenating the visible and hidden text without a pause.

Loading...
Edit live code
<TextLink href="/tariff/economy-7">
  Find out more<VisuallyHidden> about the Economy 7 tariff</VisuallyHidden>
</TextLink>

Adding currency context to inputs​

CurrencyInput uses VisuallyHidden internally to announce the currency denomination. This pattern shows how the component is used internally.

Loading...
Edit live code
<>
  <VisuallyHidden id="amount-currency" aria-hidden="true">pounds</VisuallyHidden>
  <NumberInput aria-describedby="amount-currency" />
</>

Icon-only buttons​

When a button contains only an icon, wrap the accessible label in VisuallyHidden so it is available to screen readers without affecting the visual layout.

Loading...
Edit live code
<button type="button" style={{ background: 'none', border: 0, cursor: 'pointer' }}>
  <Icon name="delete" size="1.5em" />
  <VisuallyHidden>Delete meter reading</VisuallyHidden>
</button>

For a Nebula button, use CTA Button's icon prop instead - it handles the accessible name and tooltip for you.