Skip to main content

Checkbox

Usage

Example

import Checkbox from '@mavvy/m3-ui/Checkbox';
import Text from '@mavvy/m3-ui/Text';

...

const [checked, setChecked] = useState(false);

const handleChange = () => {
setChecked((value) => !value);
}

<Checkbox
label="Default"
checked={checked}
onChange={handleChange} />

<Checkbox
label="Primary"
checked={checked}
onChange={handleChange}
color="primary" />

<Checkbox
label="Indeterminate"
checked={checked}
onChange={handleChange}
color="primary"
indeterminate
/>

<Checkbox
label="Disabled"
checked={checked}
onChange={handleChange}
color="primary"
disabled
/>

<Checkbox
label="Error"
checked={checked}
onChange={handleChange}
color="primary"
error
/>

<Checkbox
label="Disabled Error"
checked={checked}
onChange={handleChange}
color="primary"
error
disabled
/>

Default
Primary
Indeterminate
Disabled
Error
Disabled Error

Props

proptypedescription
colorColorcomponent color
checkedbooleanrequired. if true, shows a checked state
onChange(checked: boolean) => voidrequired. handler for change event
labelstring?checkbox label
textComponentstring?text component to render
textClassNamestring?text className
classNamestring?className of the component
iconClassNamestring?className for the icon
namestring?name attribute for the input element
disabledboolean?disables the checkbox
errorboolean?if true, shows an error state
indeterminateboolean?if true, shows an indeterminate state