3.0.0-alpha.4 Alpha
Light Dark Light Dark System Search /

Visually Hidden

<wa-visually-hidden> Since 2.0 stable

The visually hidden utility makes content accessible to assistive devices without displaying it on the screen.

According to The A11Y Project, "there are real world situations where visually hiding content may be appropriate, while the content should remain available to assistive technologies, such as screen readers. For instance, hiding a search field's label as a common magnifying glass icon is used in its stead."

Since visually hidden content can receive focus when tabbing, the element will become visible when something inside receives focus. This behavior is intentional, as sighted keyboard user won't be able to determine where the focus indicator is without it.

<div style="min-height: 1.875rem;">
  <wa-visually-hidden>
    <a href="#">Skip to main content</a>
  </wa-visually-hidden>
</div>

Examples

In this example, the link will open a new window. Screen readers will announce "opens in a new window" even though the text content isn't visible to sighted users.

<a href="https://example.com/" target="_blank">
  Visit External Page
  <wa-icon name="arrow-up-right-from-square" variant="regular"></wa-icon>
  <wa-visually-hidden>opens in a new window</wa-visually-hidden>
</a>

Content Conveyed By Context

Adding a label may seem redundant at times, but they're very helpful for unsighted users. Rather than omit them, you can provide context to unsighted users with visually hidden content that will be announced by assistive devices such as screen readers.

Personal Info
<wa-card style="width: 100%; max-width: 360px;">
  <header>
    <wa-visually-hidden>Personal Info</wa-visually-hidden>
  </header>
  <wa-input label="Name" style="margin-bottom: .5rem;"></wa-input>
  <wa-input label="Email" type="email"></wa-input>
</wa-card>

Slots

Name Description
(default) The content to be visually hidden.

Importing

The autoloader is the recommended way to import components. If you prefer to do it manually, use one of the following code snippets.

CDN npm React

To manually import this component from the CDN, use the following code.

import 'https://early.webawesome.com/webawesome@3.0.0-alpha.4/dist/components/visually-hidden/visually-hidden.js';
Coming soon! Coming soon!
    No results