ant-design/components/radio/demo/radiogroup-more.md

46 lines
977 B
Markdown
Raw Normal View History

2016-03-31 09:40:55 +08:00
---
order: 2
title:
zh-CN: Radio.Group 垂直
en-US: Vertical Radio.Group
---
## zh-CN
垂直的 Radio.Group配合更多输入框选项。
## en-US
Vertical Radio.Group, with more radios.
```tsx
import type { RadioChangeEvent } from 'antd';
2022-05-23 14:37:16 +08:00
import { Input, Radio, Space } from 'antd';
import React, { useState } from 'react';
2018-06-27 15:55:04 +08:00
const App: React.FC = () => {
const [value, setValue] = useState(1);
2018-06-27 15:55:04 +08:00
const onChange = (e: RadioChangeEvent) => {
console.log('radio checked', e.target.value);
setValue(e.target.value);
2019-05-07 14:57:32 +08:00
};
2018-06-27 15:55:04 +08:00
return (
<Radio.Group onChange={onChange} value={value}>
<Space direction="vertical">
<Radio value={1}>Option A</Radio>
<Radio value={2}>Option B</Radio>
<Radio value={3}>Option C</Radio>
<Radio value={4}>
More...
{value === 4 ? <Input style={{ width: 100, marginLeft: 10 }} /> : null}
</Radio>
</Space>
</Radio.Group>
);
};
export default App;
```