-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6c70f79
commit 8b2fe22
Showing
4 changed files
with
71 additions
and
1 deletion.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
docs/data/base/getting-started/accessibility/accessibility.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Accessibility | ||
|
||
<p class="description"> | ||
Accessibility is our top priority for Base UI components. | ||
However, the library cannot make your application fully accessible. | ||
This page highlights the most common actions you, as an application developer, need to take to ensure your product is accessible. | ||
</p> | ||
|
||
Base UI components implement the . | ||
|
||
## Keyboard navigation | ||
|
||
As the Base UI components follow the [WAI-ARIA 1.2 standard](https://www.w3.org/TR/wai-aria-1.2/), they are accessible with a keyboard. | ||
This is important for users who have trouble using a pointing device, but also comes in handy for users who find navigating with a keyboard faster and expect web components to behave the same way as native operating system controls. | ||
|
||
Specifically, interactive components can be focused using the <kbd>Tab</kbd> key. | ||
List-like components (such as Select, Menu, etc.) can be browsed and activated using arrow keys, <kbd>Home</kbd>, <kbd>End</kbd>, <kbd>Enter</kbd>/<kbd>Return</kbd> and <kbd>Escape</kbd>. | ||
The Select and Menu also let users navigate to options that begin with a provided string by pressing alphanumeric keys. | ||
|
||
## Focus ring | ||
|
||
While Base UI components handle keyboard navigation, it's the developers' responsibility to indicate when a component is focused and can receive keyboard input. | ||
This is usually done by styling the [`:focus`](https://developer.mozilla.org/en-US/docs/Web/CSS/:focus) or [`:focus-visible`](https://developer.mozilla.org/en-US/docs/Web/CSS/:focus-visible) pseudoclasses. | ||
The [WCAG guidelines](https://www.w3.org/WAI/WCAG22/Understanding/focus-appearance-minimum) specify the required appearance of focused elements. | ||
|
||
## Color contrast | ||
|
||
As Base UI controls are unstyled, it's up to you to ensure appropriate contrast between text and background. | ||
You can use online tools such as https://cliambrown.com/contrast/ to measure contrast between colors (note that it uses the [APCA algorithm](https://ruitina.com/apca-accessible-colour-contrast/) that's being considered for the WCAG 3 guidelines). | ||
|
||
## Accessible labels | ||
|
||
It is also your responsibility to ensure that components have accessible names. | ||
|
||
For form controls (such as the [Input](/base-ui/react-input/), [Number Input](/base-ui/react-number-input/), [Select](/base-ui/react-select/), etc.), this requires adding an associated `<label>` element or placing an `aria-label` attribute on the component itself: | ||
|
||
```jsx | ||
<label> | ||
First name <Input /> | ||
</label> | ||
``` | ||
|
||
or | ||
|
||
```jsx | ||
<label for="first-name">First name</label> | ||
<Input id="first-name" /> | ||
``` | ||
|
||
or | ||
|
||
```jsx | ||
<Input aria-label="First name" /> | ||
``` | ||
|
||
For buttons, their inner text becomes the accessible label. | ||
You only need to place an `aria-label` attribute if the button contains no text (like an icon button). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import * as React from 'react'; | ||
import MarkdownDocs from 'docs/src/modules/components/MarkdownDocsV2'; | ||
import AppFrame from 'docs/src/modules/components/AppFrame'; | ||
import * as pageProps from 'docs/data/base/getting-started/accessibility/accessibility.md?@mui/markdown'; | ||
|
||
export default function Page() { | ||
return <MarkdownDocs {...pageProps} />; | ||
} | ||
|
||
Page.getLayout = (page) => { | ||
return <AppFrame>{page}</AppFrame>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters