Skip to content

Commit 320f2fc

Browse files
authored
Update README.md
1 parent 8de1b52 commit 320f2fc

File tree

1 file changed

+29
-21
lines changed

1 file changed

+29
-21
lines changed

README.md

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function App() {
2727
}
2828
```
2929

30-
To add some accessibility features to your scene you'll have to wrap objects you want to make focusable with the `A11y` component:
30+
To add accessibility features to your scene you'll have to wrap components you want to make focusable with the `A11y` component:
3131

3232
```jsx
3333
import { A11y } from '@react-three/a11y'
@@ -37,17 +37,16 @@ import { A11y } from '@react-three/a11y'
3737
</A11y>
3838
```
3939

40-
At this point both `MyComponent` can receive focus. More accurately, the emulated "focus" will be on the parent `A11y` that will act as a provider and let its children access its state. But even if objects are focusable, nothing will be displayed or read without a few more attributes.
40+
`MyComponent` can now receive focus. More accurately, the emulated "focus" will handled at the `A11y` components which acts as a provider for children to access its state. But even if objects are focusable, nothing will be displayed or shown by default.
4141

4242
## Accessing the hover, focused & pressed state
4343

44-
For each child wrapped in a `A11y` component, you can access the `focus` / `hover` / `pressed` state like so:
44+
For each child wrapped in the `A11y` component, you can access the `focus`, `hover` and `pressed` state like so:
4545

4646
```jsx
4747
import { useA11y } from '@react-three/a11y'
4848

4949
function Box(props) {
50-
//useA11y gives us access to hover, focus and pressed states
5150
const a11y = useA11y()
5251
return (
5352
<mesh {...props}>
@@ -58,14 +57,6 @@ function Box(props) {
5857
}
5958
```
6059

61-
## The role attribute
62-
63-
Like in HTML, you can focus different kind of elements and expect different things depending on what you're focusing:
64-
65-
- `role="content"` ( default ) <a href="/#content">More below </a>
66-
- `role="button"` <a href="/#button">More below </a>
67-
- `role="link"` <a href="/#link">More below </a>
68-
6960
## Call function on focus
7061

7162
The `focusCall` prop of `A11y` will be called each time this component receives focus (usually through tab navigation).
@@ -109,29 +100,46 @@ If your `A11y` component has the `role="button"`, you can use three more props:
109100
description="This button can enable dark theme. Dark theme is off"
110101
pressedDescription="This button can disable dark theme. Dark theme is on"
111102
activationMsg="Dark theme enabled"
112-
deactivationMsg="Dark theme disabled"
113-
... />
103+
deactivationMsg="Dark theme disabled" ... />
114104
```
115105

116106
## The three roles of the `A11y` component
117107

118-
#### `content`
108+
Like in HTML, you can focus different kind of elements and expect different things depending on what you're focusing.
109+
110+
#### Content
111+
112+
```jsx
113+
<A11y role="content" ... />
114+
```
115+
116+
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.
119117

120-
Uses `cursor: default`.
118+
#### Buttons
121119

122-
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.
123120

124-
#### `button`
121+
```jsx
122+
<A11y
123+
role="button"
124+
activationMsg="Button activated"
125+
deactivationMsg="Button deactivated"
126+
pressedDescription="Button pressed" ... />
127+
```
125128

126-
Uses `cursor: pointer`. Special attributes: activationMsg, deactivationMsg, pressedDescription
129+
Uses the `pointer` cursor. Special attributes: `activationMsg`, `deactivationMsg` and `pressedDescription`.
127130

128131
This role is meant to emulate the behaviour of a button or a togglable 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 actionnable by user using a screen reader.
129132

130133
You can turn it into a button with aria-pressed by providing the following properties deactivationMsg, pressedDescription in addition to the usual description and activationMsg properties.
131134

132-
#### `link`
135+
#### Links
136+
137+
138+
```jsx
139+
<A11y role="link" href="https://url.com" ... />
140+
```
133141

134-
Uses `cursor: pointer`. Special attributes: href.
142+
Uses this `pointer` cursor. Special attributes: `href`.
135143

136144
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. Just like the button one, it is accessible to all kind of user.
137145

0 commit comments

Comments
 (0)