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