Skip to content

Commit edb1000

Browse files
authored
Update README.md
readme v1
1 parent e623821 commit edb1000

File tree

1 file changed

+44
-13
lines changed

1 file changed

+44
-13
lines changed

README.md

Lines changed: 44 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ You can for instance use it in order to make sure the currently focused element
114114
```jsx
115115
import { A11yAnnouncer, A11y } from "@react-three/a11y"
116116

117-
<A11yDom >
118117
<Canvas>
119118
{...}
120119
<A11y role="content" focusCall={()=>{
@@ -124,7 +123,7 @@ You can for instance use it in order to make sure the currently focused element
124123
</A11y>
125124
{...}
126125
</Canvas>
127-
</A11yDom>
126+
<A11yAnnouncer />
128127
```
129128

130129
## Call function on click / keyboard Click
@@ -134,7 +133,6 @@ The A11y attribute actionCall will call the associated function each time this c
134133
```jsx
135134
import { A11yAnnouncer, A11y } from "@react-three/a11y"
136135

137-
<A11yDom >
138136
<Canvas>
139137
{...}
140138
<A11y role="button" actionCall={()=>{
@@ -144,7 +142,7 @@ The A11y attribute actionCall will call the associated function each time this c
144142
</A11y>
145143
{...}
146144
</Canvas>
147-
</A11yDom>
145+
<A11yAnnouncer />
148146
```
149147

150148
## Provide a description of the currenlty focused / hovered element
@@ -155,7 +153,6 @@ Optionnaly, you can also show the description to the user when he hover it by se
155153
```jsx
156154
import { A11yAnnouncer, A11y } from "@react-three/a11y"
157155

158-
<A11yDom >
159156
<Canvas>
160157
{...}
161158
<A11y role="content" description="A rotating red square">
@@ -169,17 +166,17 @@ Optionnaly, you can also show the description to the user when he hover it by se
169166
</A11y>
170167
{...}
171168
</Canvas>
172-
</A11yDom>
169+
<A11yAnnouncer />
173170
```
174171

175-
If your A11y component have the role="button", you can use two more attributes :
172+
If your A11y component have the role="button", you can use three more attributes :
176173
- activationMsg : When the user will click / activate the "button" the screen reader will read what you wrote in activationMsg
177174
- desactivationMsg : When set, it turns your button in a togglable button. Which means he now has a on/off state. Screen readers will read the state of the button as well as the desactivation message / activation message that you set when toggling it.
175+
- pressedDescription : When set, it turns your button in a togglable button. Which means he now has a on/off state. This will be read instead of the usual description when the button is on.
178176

179177
```jsx
180178
import { A11yAnnouncer, A11y } from "@react-three/a11y"
181179

182-
<A11yDom >
183180
<Canvas>
184181
{...}
185182
<A11y role="button" description="This button will send a thank you email to the team" activationMsg="Email is sending">
@@ -189,7 +186,8 @@ If your A11y component have the role="button", you can use two more attributes :
189186
{...}
190187
<A11y
191188
role="button"
192-
description="This button can enable and disable dark theme"
189+
description="This button can enable dark theme. Dark theme is off"
190+
pressedDescription="This button can disable dark theme. Dark theme is on"
193191
activationMsg="Dark theme enabled"
194192
desactivationMsg="Dark theme disabled"
195193
>
@@ -198,17 +196,50 @@ If your A11y component have the role="button", you can use two more attributes :
198196
</A11y>
199197
{...}
200198
</Canvas>
201-
</A11yDom>
199+
<A11yAnnouncer />
202200
```
203201

204-
####content
202+
## the three role of the A11y component
203+
#### content
204+
cursor: default
205+
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.
206+
It's not meant to trigger anything on click or to be activable with the Keyboard.
207+
Therefore it won't show a pointer cursor on hover.
205208

206-
####button
209+
#### button
210+
cursor: pointer
211+
Special attributes : activationMsg, desactivationMsg, pressedDescription
212+
This role is meant to emulate the behaviour of a button or a togglable button.
213+
It will display a cursor pointer when your cursor is over the linked 3D object.
214+
It will call a function on click but also on any kind of action that would trigger a focused button ( Enter, Double-Tap .. )
215+
It is also actionnable by user using a screen reader.
216+
You can turn it into a button with aria-pressed by providing the following properties desactivationMsg, pressedDescription in addition to the usual description and activationMsg properties.
207217

208-
####link
218+
#### link
219+
cursor: pointer
220+
Special attributes : href
221+
This role is meant to emulate the behaviour of a regular html link.
222+
It should be used in combination with something that will trigger navigation on click.
223+
Just like the button one, it is accessible to all kind of user.
224+
```diff
225+
- Don't forget to provide the href attribute as he is required for screen readers to read it correctly !
226+
- It will have no effect on the navigation, it's just used as information
227+
```
209228

210229
## Screen reader support
211230

231+
In order to provide informations to screen reader users and use this package at its full potential, fill the description attribute of all your A11y components and use the appropriate role attribute on each of them.
232+
233+
## Additionals features
234+
235+
Use a custom tabindex with for your A11y components by providing a number to the tabIndex attribute
236+
```jsx
237+
<A11y tabIndex={2} >
238+
<My3DSquare />
239+
</A11y>
240+
```
241+
More about the use of tabIndex on <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex">developer.mozilla.org</a>
242+
212243
## Next steps
213244

214245
- [ ] Improve the accessibility for mobile screen readers such as Voice Over and Talk Back

0 commit comments

Comments
 (0)