Skip to content

Commit

Permalink
docs(Loading): add accessibility section
Browse files Browse the repository at this point in the history
  • Loading branch information
sarkaaa committed Feb 17, 2025
1 parent 2682c4c commit 3b71330
Showing 1 changed file with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
title: Accessibility
redirect_from:
- /components/loading/accessibility/
---

# Accessibility

## Loading

The Loading component has been designed with accessibility in mind.

The component offers flexibility in terms of the HTML element used for the root node. By default, it will render a `div` element.

### Title

Optional prop `title` allows you to specify a `title` value of the loading (svg) icon. This value is announced by a screen reader. This prop should ideally be translated.

### AsComponent

The prop `asComponent` is optional and it is set to a `div` by default.
This can be used when the `Loading` component is wrapped by another component which requires a [phrasing element](https://developer.mozilla.org/en-US/docs/Web/HTML/Content_categories) as a children.

Be aware that `Loading` component is **always** rendered as a `div` element when the prop `text` is filled in.

### Example

```jsx
<Button>
<Loading title="Title of the button is loading" asComponent="span" />
</Button>
```

We have a `Loading` component inside a `Button` component (which requires phrasing element as a children). In this case, we can use the `asComponent` prop to specify the root node of the `Loading` component.

The screen reader will announce the value title (`Title of the button is loading`).

0 comments on commit 3b71330

Please sign in to comment.