Checkboxes

Checkboxes lets you create a group of checkboxes.


Make checkboxes easily

Just pass an array of strings into checkboxes and Checkboxes takes care of the rest for you.

<Checkboxes
checkboxes={['apple', 'banana', 'carrot']}
/>

Wrapped in Fieldset, as it should be

Checkboxes wraps checkboxes in a <fieldset> element since they’re related. You can also provide an optional label with legend.

<Checkboxes
legend="Your choice of fruits:"
checkboxes={[ 'apple', 'banana', 'carrot' ]}
/>
Your choice of fruits:

Add custom labels easily

If you like to use custom labels for each checkbox, just pass an array of objects into the checkboxes property instead.

<Checkboxes
checkboxes={[
{ name: 'apple', label: '🍎 Apple'},
{ name: 'banana', label: '🍌 Banana'},
{ name: 'carrot', label: 'πŸ₯• Carrot'},
]}
/>

Make everything checked, disabled, or readonly at once

Checkboxes give you a convenient way to make everything checked, disabled, or readonly. Just use the relevant properties to make it happen.

<Checkboxes
legend="Your choice of fruits:"
checkboxes={[ 'apple', 'banana', 'carrot' ]}
checked
disabled
/>
Your choice of fruits:

Or make any checkbox, disabled, or read-only β€” at your discretion

Just set checked, disabled, or readonly to true for each checkbox.

<Checkboxes
legend="Your choice of fruits:"
checkboxes={[
{ name: 'apple', label: '🍎 Apple', checked: true, readonly: true },
{ name: 'banana', label: '🍌 Banana'},
{ name: 'carrot', label: 'πŸ₯• Carrot'},
]}
/>
Your choice of fruits:

Add an β€œOthers” option with minimal effort

A list of checkboxes sometimes contain an Others field that lets a user type into. You can create this simply by adding hasInput to the checkbox object.

<Checkboxes
legend="Your choice of fruits:"
checkboxes={[
{ name: 'apple' },
{ name: 'banana' },
{ name: 'carrot' },
{ name: 'others', hasInput: true },
]}
/>
Your choice of fruits: