Checkbox
A control that allows the user to toggle between checked and not checked.
Indeterminate
Idle (on)
Hover (on)
Idle (off)
Hover (off)
Disabled (on)
Disabled (off)
Basic example
The most basic use-case involves using a FormControlLabel
and a Checkbox
component, both of which are exported.
Wrapping the Checkbox
component in a FormControlLabel
will make it possible to click on the text and toggle the value, and display text next to it with the proper design features.
import {
Checkbox,
FormControlLabel
} from '@streamelements/frontend-ui';
// ...
<FormControlLabel>
<Checkbox />
Toggle
</FormControlLabel>
API
Checkbox
Name | Type | Default value | Description |
defaultChecked | boolean | false | When true, the initial state will be checked |
checked | boolean | "indeterminate" | – | The controlled state of component. Must be used in conjunction with onCheckedChange |
onCheckedChange | Function | – | Callback function to be called when the state changes (checked: boolean | 'indeterminate') => void |
disabled | boolean | – | When true, prevents user interaction with the component. |
required | boolean | – | When true, the user must check the Checkbox before the parent form can be submitted. |
name | string | – | The name of the Checkbox. Submitted with its parent form. |
value | string | on | The value given as data when submitted with a name . |
FormControlLabel
Check out the Form Control Label page