|
@@ -28,7 +28,7 @@ import React from 'react';
|
|
|
import { Radio } from '@douyinfe/semi-ui';
|
|
|
|
|
|
() => (
|
|
|
- <Radio aria-label="Radio demo">Radio</Radio>
|
|
|
+ <Radio aria-label="Radio demo" name="demo-radio">Radio</Radio>
|
|
|
);
|
|
|
|
|
|
```
|
|
@@ -45,7 +45,7 @@ import { Radio } from '@douyinfe/semi-ui';
|
|
|
|
|
|
|
|
|
() => (
|
|
|
- <Radio extra="Semi Design is a design system developed and maintained by IES Front-end Team and UED Team" aria-label="Radio demo">
|
|
|
+ <Radio extra="Semi Design is a design system developed and maintained by IES Front-end Team and UED Team" aria-label="Radio demo" name="demo-radio-extra">
|
|
|
Semi Design
|
|
|
</Radio>
|
|
|
);
|
|
@@ -75,11 +75,11 @@ class App extends React.Component {
|
|
|
render() {
|
|
|
return (
|
|
|
<div>
|
|
|
- <Radio defaultChecked={false} disabled={this.state.disabled} aria-label="Radio demo">
|
|
|
+ <Radio defaultChecked={false} disabled={this.state.disabled} aria-label="Radio demo" name="demo-radio-disabled">
|
|
|
Disabled
|
|
|
</Radio>
|
|
|
<br />
|
|
|
- <Radio defaultChecked disabled={this.state.disabled} aria-label="Radio demo">
|
|
|
+ <Radio defaultChecked disabled={this.state.disabled} aria-label="Radio demo" name="demo-radio-defaultChecked-disabled">
|
|
|
Disabled
|
|
|
</Radio>
|
|
|
<div style={{ marginTop: 20 }}>
|
|
@@ -120,7 +120,7 @@ class App extends React.Component {
|
|
|
render() {
|
|
|
return (
|
|
|
<div>
|
|
|
- <Radio checked={this.state.checked} mode="advanced" onChange={this.onChange} aria-label="Radio demo">
|
|
|
+ <Radio checked={this.state.checked} mode="advanced" onChange={this.onChange} aria-label="Radio demo" name="demo-radio-advanced">
|
|
|
Click Again to Uncheck
|
|
|
</Radio>
|
|
|
</div>
|
|
@@ -154,7 +154,7 @@ class App extends React.Component {
|
|
|
|
|
|
render() {
|
|
|
return (
|
|
|
- <RadioGroup onChange={this.onChange} value={this.state.value} aria-label="RadioGroup demo">
|
|
|
+ <RadioGroup onChange={this.onChange} value={this.state.value} aria-label="RadioGroup demo" name="demo-radio-group">
|
|
|
<Radio value={1}>A</Radio>
|
|
|
<Radio value={2}>B</Radio>
|
|
|
<Radio value={3}>C</Radio>
|
|
@@ -165,6 +165,24 @@ class App extends React.Component {
|
|
|
}
|
|
|
```
|
|
|
|
|
|
+### vertical arrangement
|
|
|
+
|
|
|
+The radio elements in the group can be arranged horizontally or vertically by setting the `direction` property to the RadioGroup
|
|
|
+
|
|
|
+```jsx live=true
|
|
|
+import React from 'react';
|
|
|
+import { RadioGroup, Radio } from '@douyinfe/semi-ui';
|
|
|
+
|
|
|
+() => (
|
|
|
+ <RadioGroup direction="vertical" aria-label="RadioGroup demo" name="demo-radio-group-vertical">
|
|
|
+ <Radio value={1}>A</Radio>
|
|
|
+ <Radio value={2}>B</Radio>
|
|
|
+ <Radio value={3}>C</Radio>
|
|
|
+ <Radio value={4}>D</Radio>
|
|
|
+ </RadioGroup>
|
|
|
+);
|
|
|
+```
|
|
|
+
|
|
|
### Button Style
|
|
|
|
|
|
version: >=1.26.0
|
|
@@ -211,17 +229,17 @@ class App extends React.Component {
|
|
|
render() {
|
|
|
return (
|
|
|
<Space vertical spacing="loose" align="start">
|
|
|
- <RadioGroup type="button" buttonSize="small" onChange={this.onChange1} value={this.state.value1} aria-label="RadioGroup demo">
|
|
|
+ <RadioGroup type="button" buttonSize="small" onChange={this.onChange1} value={this.state.value1} aria-label="RadioGroup demo" name="demo-radio-small">
|
|
|
<Radio value={1}>Instant push</Radio>
|
|
|
<Radio value={2}>Timed push</Radio>
|
|
|
<Radio value={3}>Dynamic push</Radio>
|
|
|
</RadioGroup>
|
|
|
- <RadioGroup type="button" buttonSize="middle" onChange={this.onChange2} value={this.state.value2} aria-label="RadioGroup demo">
|
|
|
+ <RadioGroup type="button" buttonSize="middle" onChange={this.onChange2} value={this.state.value2} aria-label="RadioGroup demo" name="demo-radio-middle">
|
|
|
<Radio value={1}>Instant push</Radio>
|
|
|
<Radio value={2}>Timed push</Radio>
|
|
|
<Radio value={3}>Dynamic push</Radio>
|
|
|
</RadioGroup>
|
|
|
- <RadioGroup type="button" buttonSize="large" onChange={this.onChange3} value={this.state.value3} aria-label="RadioGroup demo">
|
|
|
+ <RadioGroup type="button" buttonSize="large" onChange={this.onChange3} value={this.state.value3} aria-label="RadioGroup demo" name="demo-radio-large">
|
|
|
<Radio value={1}>Instant push</Radio>
|
|
|
<Radio value={2}>Timed push</Radio>
|
|
|
<Radio value={3}>Dynamic push</Radio>
|
|
@@ -243,7 +261,7 @@ import React from 'react';
|
|
|
import { RadioGroup, Radio } from '@douyinfe/semi-ui';
|
|
|
|
|
|
() => (
|
|
|
- <RadioGroup type='card' defaultValue={1} direction='vertical' aria-label="RadioGroup demo">
|
|
|
+ <RadioGroup type='card' defaultValue={1} direction='vertical' aria-label="RadioGroup demo" name="demo-radio-group-card">
|
|
|
<Radio value={1} extra='Radio description' style={{width:280}}>
|
|
|
Radio Title
|
|
|
</Radio>
|
|
@@ -269,7 +287,7 @@ import React from 'react';
|
|
|
import { RadioGroup, Radio } from '@douyinfe/semi-ui';
|
|
|
|
|
|
() => (
|
|
|
- <RadioGroup type='pureCard' defaultValue={1} direction='vertical' aria-label="RadioGroup demo">
|
|
|
+ <RadioGroup type='pureCard' defaultValue={1} direction='vertical' aria-label="RadioGroup demo" name="demo-radio-group-pureCard">
|
|
|
<Radio value={1} extra='Radio description' style={{width:280}}>
|
|
|
Radio Title
|
|
|
</Radio>
|
|
@@ -338,13 +356,13 @@ class App extends React.Component {
|
|
|
render() {
|
|
|
return (
|
|
|
<div>
|
|
|
- <RadioGroup options={this.plainOptions} onChange={this.onChange1} value={this.state.value1} aria-label="RadioGroup demo" />
|
|
|
+ <RadioGroup options={this.plainOptions} onChange={this.onChange1} value={this.state.value1} aria-label="RadioGroup demo" name="demo-radio-group-1"/>
|
|
|
<br />
|
|
|
<br />
|
|
|
- <RadioGroup options={this.optionsWithDisabled} onChange={this.onChange3} value={this.state.value3} aria-label="RadioGroup demo" />
|
|
|
+ <RadioGroup options={this.optionsWithDisabled} onChange={this.onChange2} value={this.state.value2} aria-label="RadioGroup demo" name="demo-radio-group-2"/>
|
|
|
<br />
|
|
|
<br />
|
|
|
- <RadioGroup options={this.options} onChange={this.onChange2} value={this.state.value2} aria-label="RadioGroup demo" />
|
|
|
+ <RadioGroup options={this.options} onChange={this.onChange3} value={this.state.value3}aria-label="RadioGroup demo" name="demo-radio-group-3"/>
|
|
|
</div>
|
|
|
);
|
|
|
}
|
|
@@ -361,6 +379,7 @@ class App extends React.Component {
|
|
|
| addonId | id of addon node, aria-labelledby refers to this id, if not set, it will generate an id randomly **provided after v2.11.0** | string | |
|
|
|
| addonStyle | inline style of content wrapper<br/>**provided after v1.16.0** | object | |
|
|
|
| aria-label | Label of Radio | string | - |
|
|
|
+| name | The `name` attribute passed to `input[type="radio"]` in the Radio component, Radios with the same `name` belong to the same RadioGroup,The `name` attribute can refer to [MDN Radio](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input/radio#value) | string | - |
|
|
|
| autoFocus | Automatically focus the form control when the page is loaded | boolean | false |
|
|
|
| checked | Specify whether it is currently selected | boolean | false |
|
|
|
| className | Class name | string | |
|
|
@@ -402,16 +421,23 @@ class App extends React.Component {
|
|
|
|
|
|
## Accessibility
|
|
|
|
|
|
-### Keyboard and Focus
|
|
|
-
|
|
|
-- Card type and button type Radio group can be selected by arrow switch
|
|
|
-
|
|
|
### ARIA
|
|
|
|
|
|
- `aria-label`: used to explain the role of Radio or RadioGroup
|
|
|
- `aria-labelledby` points to the addon node, used to explain the content of Radio
|
|
|
- `aria-describedby` points to the extra node, which is used to explain the content of Radio
|
|
|
|
|
|
+### Keyboard and focus
|
|
|
+WAI-ARIA: https://www.w3.org/WAI/ARIA/apg/patterns/radiobutton/
|
|
|
+
|
|
|
+- RadioGroup can be focused, the initial focus acquisition rules are as follows:
|
|
|
+ - When there is no selected item in the RadioGroup, the initial focus is on the first Radio item;
|
|
|
+ - When there are selected items in the RadioGroup, the initial focus is on the selected Radio item.
|
|
|
+- For radios belonging to the same radiogroup:
|
|
|
+ - You can use `Right arrow` or `Down arrow` to move the focus to the next Radio item, uncheck the previously focused Radio item, and select the currently focused Radio item;
|
|
|
+ - You can Use `Left Arrow` or `Up Arrow` to move the focus to the previous Radio item, at the same time uncheck the previously focused Radio item, and select the currently focused Radio item.
|
|
|
+- If there is no item selected in the RadioGroup, you can use the `Space` key to select the initial focus.
|
|
|
+
|
|
|
<!-- ## Related Material
|
|
|
|
|
|
```material
|