Skip to content

Spinner is inaccessible by default #3942

@iansan5653

Description

@iansan5653

The Spinner component is, at first glance, a convenient way to render a loading state:

<Box>
  {isLoading ? <Spinner /> : content}
</Box>

This appears straightforward, but in reality this is a bad idea because it's completely inaccessible. Spinner has no label by default, so the box will simply appear empty to screen readers.

The US Government CMS design system renders Spinner as a status with hidden "Loading" text. I think we probably should do the same by default, rendering it like so (hiding the SVG to avoid duplication):

<Box role="status">
  <VisuallyHidden>Loading</VisuallyHidden>
  <SpinnerSvg aria-hidden />
</Box>

This would make the accessible path much easier to follow.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions