Checkbox
Capture boolean input from user
Import
Source
Docs
Package
Usage
LabelPosition
Color
Shades
Radius
xs
sm
md
lg
xl
Size
xs
sm
md
lg
xl
States
Replace icon
Sizes
Checkbox has 5 predefined sizes: xs, sm, md, lg, xl. Size defines label font-size, input width and height:
Indeterminate state
Checkbox supports indeterminate state. When indeterminate
prop is true,
checked
prop is ignored:
Controlled
Label with link
Checkbox.Group
Select your favorite frameworks/libraries
This is anonymous
Controlled Checkbox.Group
Get input ref
You can get input ref by setting ref
prop:
Accessibility
Provide aria-label
in case you use checkbox without label for screen reader support:
Checkbox component props
Name | Type | Description |
---|---|---|
color | MantineColor | Key of theme.colors |
description | ReactNode | Description, displayed after the label |
error | ReactNode | Error message displayed after the input |
icon | FC<{ indeterminate: boolean; className: string; }> | Icon rendered when checkbox has checked or indeterminate state |
indeterminate | boolean | Indeterminate state of checkbox, if set, `checked` prop is ignored |
label | ReactNode | Checkbox label |
labelPosition | "left" | "right" | Position of the label |
radius | number | "xs" | "sm" | "md" | "lg" | "xl" | Key of theme.radius or any valid CSS value to set border-radius, theme.defaultRadius by default |
size | number | "xs" | "sm" | "md" | "lg" | "xl" | Controls label font-size and checkbox width and height |
transitionDuration | number | Transition duration in ms |
wrapperProps | Record<string, any> | Props added to the root element |
Checkbox.Group component props
Name | Type | Description |
---|---|---|
children * | ReactNode | <Checkbox /> components |
defaultValue | string[] | Initial selected checkboxes, use for uncontrolled components, overridden by value prop |
description | ReactNode | Input description, displayed after label |
descriptionProps | Record<string, any> | Props spread to description element |
error | ReactNode | Displays error message after input |
errorProps | Record<string, any> | Props spread to error element |
inputContainer | (children: ReactNode) => ReactNode | Input container component, defaults to React.Fragment |
inputWrapperOrder | ("input" | "label" | "error" | "description")[] | Controls order of the Input.Wrapper elements |
label | ReactNode | Input label, displayed before input |
labelProps | Record<string, any> | Props spread to label element |
onChange | (value: string[]) => void | Called when value changes |
required | boolean | Adds required attribute to the input and red asterisk on the right side of label |
size | "xs" | "sm" | "md" | "lg" | "xl" | Controls label font-size and checkbox width and height |
value | string[] | Value of selected checkboxes, use for controlled components |
withAsterisk | boolean | Determines whether required asterisk should be rendered, overrides required prop, does not add required attribute to the input |
wrapperProps | Record<string, any> | Props added to Input.Wrapper component (root element) |
Checkbox component Styles API
Name | Static selector | Description |
---|---|---|
root | .asuikit-Checkbox-root | Root button element |
body | .asuikit-Checkbox-body | Main element of checkbox |
inner | .asuikit-Checkbox-inner | Includes input and label |
labelWrapper | .asuikit-Checkbox-labelWrapper | Include label and description component |
input | .asuikit-Checkbox-input | Checkbox input element |
icon | .asuikit-Checkbox-icon | Checked or indeterminate state icon |
error | .asuikit-Checkbox-error | Error message |
description | .asuikit-Checkbox-description | Description |
label | .asuikit-Checkbox-label | Label |