-
-
Notifications
You must be signed in to change notification settings - Fork 883
Expand file tree
/
Copy patharia.tsx
More file actions
31 lines (27 loc) · 710 Bytes
/
aria.tsx
File metadata and controls
31 lines (27 loc) · 710 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import React, {useState} from 'react';
import {render, Text, Box, useInput} from '../../src/index.js';
function AriaExample() {
const [checked, setChecked] = useState(false);
useInput(key => {
if (key === ' ') {
setChecked(!checked);
}
});
return (
<Box flexDirection="column">
<Text>
Press spacebar to toggle the checkbox. This example is best experienced
with a screen reader.
</Text>
<Box marginTop={1}>
<Box aria-role="checkbox" aria-state={{checked}}>
<Text>{checked ? '[x]' : '[ ]'}</Text>
</Box>
</Box>
<Box marginTop={1}>
<Text aria-hidden="true">This text is hidden from screen readers.</Text>
</Box>
</Box>
);
}
render(<AriaExample />);