ant-design/components/radio/demo/radiogroup-with-name.md
MadCcc 6776bb8916
docs: demo support react18 (#34843)
* docs: update demo

* chore: add script

* test: fix demo test

* docs: convert demos

* chore: move script

* test: remove react-dom import

* chore: update deps

* docs: update riddle js

* test: fix image test

* docs: fix riddle demo
2022-04-03 23:27:45 +08:00

949 B

order title
4
zh-CN en-US
单选组合 - 配合 name 使用 Radio.Group with name

zh-CN

可以为 Radio.Group 配置 name 参数,为组合内的 input 元素赋予相同的 name 属性,使浏览器把 Radio.Group 下的 Radio 真正看作是一组(例如可以通过方向键始终在同一组内更改选项)。

en-US

Passing the name property to all input[type="radio"] that are in the same Radio.Group. It is usually used to let the browser see your Radio.Group as a real "group" and keep the default behavior. For example, using left/right keyboard arrow to change your selection that in the same Radio.Group.

import { Radio } from 'antd';

const App = () => (
  <Radio.Group name="radiogroup" defaultValue={1}>
    <Radio value={1}>A</Radio>
    <Radio value={2}>B</Radio>
    <Radio value={3}>C</Radio>
    <Radio value={4}>D</Radio>
  </Radio.Group>
);

export default () => <App />;