Label and size in React Radio button component
1 Dec 20234 minutes to read
This section explains the different sizes and labels.
Label
RadioButton caption can be defined by using the label
property. This reduces the manual addition of label for RadioButton. You can customize the label position before or after the RadioButton through the labelPosition
property.
import { enableRipple } from '@syncfusion/ej2-base';
import { RadioButtonComponent } from '@syncfusion/ej2-react-buttons';
import * as React from 'react';
import * as ReactDom from 'react-dom';
enableRipple(true);
function App() {
return (<ul>
{/* Label position - Left. */}
<li><RadioButtonComponent label="Left Side Label" name="position" labelPosition="Before"/></li>
{/* Label position - Right. */}
<li><RadioButtonComponent label="Right Side Label" name="position" checked={true}/></li>
</ul>);
}
export default App;
ReactDom.render(<App />, document.getElementById('radio-button'));
import { enableRipple } from '@syncfusion/ej2-base';
import { RadioButtonComponent } from '@syncfusion/ej2-react-buttons';
import * as React from 'react';
import * as ReactDom from 'react-dom';
enableRipple(true);
function App() {
return (
<ul>
{/* Label position - Left. */}
<li><RadioButtonComponent label="Left Side Label" name="position" labelPosition="Before" /></li>
{/* Label position - Right. */}
<li><RadioButtonComponent label="Right Side Label" name="position" checked={true} /></li>
</ul>
);
}
export default App;
ReactDom.render(<App />, document.getElementById('radio-button'));
Size
The different RadioButton sizes available are default and small. To reduce the size of the default RadioButton to small, set the cssClass
property to e-small
.
import { enableRipple } from '@syncfusion/ej2-base';
import { RadioButtonComponent } from '@syncfusion/ej2-react-buttons';
import * as React from 'react';
import * as ReactDom from 'react-dom';
enableRipple(true);
function App() {
return (<ul>
{/* Small RadioButton. */}
<li><RadioButtonComponent label="Small" name="size" cssClass="e-small"/></li>
{/* Default RadioButton. */}
<li><RadioButtonComponent label="Default" name="size"/></li>
</ul>);
}
export default App;
ReactDom.render(<App />, document.getElementById('radio-button'));
import { enableRipple } from '@syncfusion/ej2-base';
import { RadioButtonComponent } from '@syncfusion/ej2-react-buttons';
import * as React from 'react';
import * as ReactDom from 'react-dom';
enableRipple(true);
function App() {
return (
<ul>
{/* Small RadioButton. */}
<li><RadioButtonComponent label="Small" name="size" cssClass="e-small" /></li>
{/* Default RadioButton. */}
<li><RadioButtonComponent label="Default" name="size" /></li>
</ul>
);
}
export default App;
ReactDom.render(<App />, document.getElementById('radio-button'));