Reputation: 1489
I'm importing Radio from antd in my project.
I need two radio buttons named "Taxable" and "Non Taxable".
import {Button, Radio, Form, Icon, Input, message,Modal,createFormField,Row,Col} from "antd";
<Row gutter={24}>
<Col span={24}>
<FormItem>
{getFieldDecorator('IsTaxable', {
initialValue: "",
rules: [{
required: true, message: 'Please Choose your option!',
}],
})(
<Radio value='true'>Taxable</Radio>
)}
</FormItem>
</Col>
</Row>
How do I include the second radio button so that I can view these radio buttons in two columns(two lines)?
Upvotes: 2
Views: 5868
Reputation: 10262
You could use Vertical RadioGroup or you can also use <br/>
tag as well.
You can check here with working stackblitz demo.
Code Snippet with style
const radioStyle = {
display: 'block',
height: '30px',
lineHeight: '30px',
};
<FormItem>
{getFieldDecorator('IsTaxable', {
initialValue: "",
rules: [{
required: true,
message: 'Please Choose your option!',
}],
})(<RadioGroup onChange={this.onChange}>
<Radio style={radioStyle} value={true}>Taxable</Radio>
<Radio style={radioStyle} value={false}>Non Taxable</Radio>
</RadioGroup>
)}
</FormItem>
Code Snippet with <br>
tag
<FormItem>
{getFieldDecorator('IsTaxable', {
initialValue: "",
rules: [{
required: true,
message: 'Please Choose your option!',
}],
})(<RadioGroup onChange={this.onChange}>
<Radio value={true}>Taxable</Radio> <br />
<Radio value={false}>Non Taxable</Radio>
</RadioGroup>
)}
</FormItem>
Upvotes: 2
Reputation: 22587
You need to custom style the radio buttons
Similar to vertical radio group demo here - https://ant.design/components/radio/
https://codesandbox.io/s/rj2692803o
const radioStyle = {
display: "block",
"margin-bottom": "5px",
"border-radius": "3px"
};
<Radio.Group defaultValue="taxable" buttonStyle="solid">
<Radio.Button value="taxable" style={radioStyle}>
Taxable
</Radio.Button>
<Radio.Button value="non-taxable" style={radioStyle}>
Non-Taxable
</Radio.Button>
</Radio.Group>
Upvotes: 2