Skip to content
Change the site theme
(information)

Screen Reader Only

Screen Reader Only is a utility that visually hides content to provide an accessible experience for users of assistive technology.


Guidelines

Guidelines page anchor

About Screen Reader Only

About Screen Reader Only page anchor

The Screen Reader Only component should be used to visually hide content that is necessary to provide appropriate context to users who experience a page using assistive technology.

When wrapped with the Screen Reader Only component, content is visually hidden but still available to assistive technology. This can be useful when information or relationships between UI controls are only communicated visually. By being able to visually hide some content you are able to provide clarifying information to non-sighted users without adding redundancy to the visual design.

Providing visually hidden headings to sectioned content

Providing visually hidden headings to sectioned content page anchor

All sectioning elements, such as Cards, should contain a heading to provide a clear document outline and form of navigation to assistive technology users. However, there may be times a heading is not required (or even redundant) in a particular UI for sighted users. By using the Screen Reader Only component you can provide a visually hidden heading to give additional context and heirarchy. In the example below, we've added "Flex" as a heading that is accessible to assistive technology, but hidden visually.

Providing clear actions while still reducing visual repetition

Providing clear actions while still reducing visual repetition page anchor

Each column in a table is required to have a column header. Sometimes those column headers can be visually hidden from sighted users if desired. To do so use the Screen Reader Only component to hide the cell content for that column header.

Another common use case is for providing correct context to repetitive actions. In the example below, the "Buy" button is clearly visually associated with the phone number via row highlighting. However, to a screen reader user, this association may not be as clear. To provide additional clarification we can add what you would be buying (Buy ) as visually hidden text to the button. This way, we can keep the same level of context for all users.

When to use Screen Reader Only

When to use Screen Reader Only page anchor

Use the Screen Reader Only component when you are required to provide additional or contextual information to a screen reader user which a sighted user maybe able to infer and when you cannot do so via semantic HTML.

Do

Use to provide additional text content to users of assistive technology

Don't

Don't use to hide interactive content


Installation

Installation page anchor
yarn add @twilio-paste/screen-reader-only - or - yarn add @twilio-paste/core
import {ScreenReaderOnly} from '@twilio-paste/core/screen-reader-only';
const Component = () => (
<Button variant="secondary" size="small">
Buy <ScreenReaderOnly>+1 (484) 662-4088</ScreenReaderOnly>
</Button>
);

All the regular HTML attributes (role, aria-*, type, and so on) including the following custom props:

PropTypeDescriptionDefault
as?keyof JSX.IntrinsicElementsA custom HTML tagspan
id?string

Black lives matter.