console.log("clicked")} ... />
```
## Provide a description of the currently focused / hovered element
When using the `description` prop in combination with the `role` prop, the `A11y` component will provide a description to the screen reader users on focus/hover.
Optionally, you can also show the description to the user on hover by setting `showAltText={true}`.
```jsx
// Reads "A rotating red square" to screen readers on focus / hover while also showing it on mouseover
// Reads "Button, open menu + (description on how to activate depending on the screen reader)" to screen readers on focus / hover
{someFunction()}} ... />
```
## The four roles of the A11y component
Like in HTML, you can focus different kind of elements and expect different things depending on what you're focusing.
#### Content
```jsx
```
Uses the `default` cursor. This role is meant to provide information to screen readers or to serve as a step for a user to navigate your site using Tab for instance. It's not meant to trigger anything on click or to be activable with the Keyboard. Therefore it won't show a pointer cursor on hover.
[Read more about role content](/a11y/roles/content)
#### Button
```jsx
```
Uses the `pointer` cursor. Special attributes: `activationMsg`.
This role is meant to emulate the behaviour of a button or a toggleable button. It will display a cursor pointer when your cursor is over the linked 3D object. It will call a function on click but also on any kind of action that would trigger a focused button (Enter, Double-Tap, ...). It is also actionable by user using a screen reader.
[Read more about role button](/a11y/roles/button)
#### ToggleButton
By using the role togglebutton, you'll emulate a button with two state that will have the `aria-pressed` attribute.
You'll then be able to use the deactivationMsg property in addition to the usual description and activationMsg properties.
```jsx
```
Special attributes: `deactivationMsg`
[Read more about role ToggleButton](/a11y/roles/togglebutton)
#### Link
```jsx
```
Uses the `pointer` cursor. Special attributes: `href`.
This role is meant to emulate the behaviour of a regular html link. It should be used in combination with something that will trigger navigation on click.
> [!NOTE]
> Don't forget to provide the href attribute as it is required for screen readers to read it correctly! - It will have no effect on the navigation, it's just used as information
[Read more about role link](/a11y/roles/link)
## Screen Reader Support
In order to provide informations to screen reader users and use this package at its full potential, fill the `description` prop of all your `A11y` components and use the appropriate `role` prop on each of them.
### Use of section
For screen readers, it might be useful to provide additional information on how to use some unconventional UI.
You can do it by wrapping the concerned part of your code relative to this UI in the A11ySection like so.
```jsx
[...]
```
## Access user preferences
The A11yUserPreferences component is available in order to access user preferences such as
- prefers-reduced-motion
- prefers-color-scheme
Take a look at [the A11yUserPreferences page](/a11y/access-user-preferences) or the [demo](https://n4rzi.csb.app) to see it in action and how to use it. The demo will adapt to your system preferences.
## Additional Features
Use a custom tabindex with for your A11y components by providing a number to the tabIndex attribute
```jsx
```
> [!CAUTION]
> Avoid using `tabindex` values greater than 0. Doing so makes it difficult for people who rely on assistive technology to navigate and operate page content.
> Instead, write the document with the elements in a logical sequence. More about the use of tabIndex on [developer.mozilla.org](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex)
]]>
[...]
```
Then, you can access the preferences in each children component where you might need them.
## Reduce motions / animations for the users that request it
Some user on your website might need all animation turned off or limited to what's strictly necessary.
For those users, if your app has an animation going somewhere, consider cancelling it for those who request it.
You can do it like so.
```jsx
const My3dObject = () => {
// this const will give you access to the user preferences
const { a11yPrefersState } = useUserPreferences()
const mesh = useRef()
// Rotate mesh every frame
useFrame(() => {
//unless the user prefers reduced motion
if (!a11yPrefersState.prefersReducedMotion) {
mesh.current.rotation.x = mesh.current.rotation.y += 0.01
}
})
return (
)
}
```
## Adapt colour scheme depending on the user preference
Some user on your website might need a darker / lighter theme. You can adapt your components according to it like so.
```jsx
const My3dObject = () => {
// this const will give you access to the user preferences
const { a11yPrefersState } = useUserPreferences()
const mesh = useRef()
return (
)
}
```
## Use the context outside and inside the r3f canvas
At the moment React context [can not be readily used between two renderers](https://github.com/pmndrs/react-three-fiber/issues/43), this is due to a problem within React.
If react-dom use the A11yUserPreferences provider, you will not be able to consume it within `
```
That's it !
Now if you inspect the dom of your app, you will see that a `` tag has been added with your text inside.
That way, user with a screenreader will be able to read that text too.
> [!NOTE]
> For people using screen readers it will also sync some kind of focus indicator natively where your text is so people so screen readers users will know where they're currently in your page.
This role can also be used to serve as a step for a user to navigate your site using Tab for instance.
For that you would need to add the tabIndex prop and the focusCall prop like so.
```jsx
someFunction()}
>
```
On focus, you could rotate the camera to show that second piece of text that would usually have required some scrolling to display.
Use it as you please but keep in mind how it might impact the accessibility.
For this example, screenreader don't trigger focus when swiping their screen so it would benefit people used to navigate through keyboard without hurting screenreader users.
It's not meant to trigger anything on click or to be activable with the Keyboard. Therefore it won't show a pointer cursor on hover.
]]>
sendEmail()}
... >
```
Using it like this makes it focusable to all kind of users.
You should also use the useA11y() hook within the encapsulated components to adjust the rendering on hover and focus. Doing so greatly improve the accessibility of your page.
Take a look at this code sample to see how to use it.
You can also play with it in [this demo](https://n4rzi.csb.app)
```jsx
function Some3DComponent() {
const a11y = useA11y()
return (