Checkbox
Checkboxs allow the user to select one or more items from a set.
If you have multiple options appearing in a list, you can preserve space by using checkboxes instead of on/off switches. If you have a single option, avoid using a checkbox and use an on/off switch instead.
Basic Checkbox
Preview
Usage
import { Checkbox } from 'archi-ui'
<Checkbox />
Default Checked
use the defaultChecked
prop to ckeck Checkbox by default.
Preview
Size
Use the size
prop to change the size of the checkboxs.
Preview
Color
Use color
prop to apply different colors for component.
Preview
Icon
You can modifie the icon for checked using checkedIcon
prop.
Preview
Indeterminate
A checkbox input can only have two states in a form: checked or unchecked. It either submits its value or doesn’t. Visually, there are three states a checkbox can be in: checked, unchecked, or indeterminate.
You can change the indeterminate icon using the indeterminateIcon
prop.
Preview
Controlled
You can control the checkbox with the checked
and onChange
props.
Preview
Checkbox is checked: false
Checkbox API
API reference docs for the React Checkbox component.
Props
Name | Type | Default | Description |
---|---|---|---|
checked | bool | - | If true , the component is checked. |
defaultChecked | bool | - | The default checked state. Use when the component is not Controlled. |
className | string | - | Override or extend the styles applied to the component. |
size | 'sm' | 'md' | 'lg' | 'md' | The size of the component. |
color | 'primary' | 'secondary' | 'info' | 'warning' | 'success' | 'error' | 'primary' | The color of the component. |
disabled | bool | false | If true , the component is disabled. |
checkedIcon | node | - | The icon to display when the component is checked. |
indeterminate | false | - | If true , the component appears indeterminate. This does not set the native input element to indeterminate due to inconsistent behaviour across browsers, However, we set a data-indeterminate attribute on the input . |
indeterminateIcon | node | <Minus /> | The icon to display when the component is indeterminate. |
onChange | func | - | Callback fired when the state is changed. function(event: React.changeEvent) => void . You can pull out the new checked state by accessing event.target.checked (boolean). |
required | bool | false | If true , the input element is required. |
value | any | - | The value of the component. The DOM API casts this to a string. the browser uses “on” as the default value. |