Checkbox
Capture boolean input from user
Import
Source
Docs
Package
Usage
LabelPosition
Color
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 framework/library
This is anonymous
Orientation
Spacing
xs
sm
md
lg
xl
Offset
xs
sm
md
lg
xl
Size
xs
sm
md
lg
xl
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 label |
error | ReactNode | Displays error message after input |
icon | FC<{ indeterminate: boolean; className: string; }> | Icon rendered when checkbox has checked or indeterminate state |
id | string | id to connect label with input |
indeterminate | boolean | Indeterminate state of checkbox, overwrites checked |
label | ReactNode | Checkbox label |
labelPosition | "left" | "right" | Position of label |
radius | number | "xs" | "sm" | "md" | "lg" | "xl" | Key of theme.radius or number to set border-radius in px |
size | "xs" | "sm" | "md" | "lg" | "xl" | Predefined label font-size and checkbox width and height in px |
transitionDuration | number | Transition duration in ms |
wrapperProps | Record<string, any> | Props spread to wrapper element |
Checkbox.Group component props
Name | Type | Description |
---|---|---|
children * | ReactNode | <Checkbox /> components only |
defaultValue | string[] | Initial value for uncontrolled component |
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 |
offset | number | "xs" | "sm" | "md" | "lg" | "xl" | Space between label and inputs |
onChange | (value: string[]) => void | Called when value changes |
orientation | "horizontal" | "vertical" | Horizontal or vertical orientation |
required | boolean | Adds required attribute to the input and red asterisk on the right side of label |
size | "xs" | "sm" | "md" | "lg" | "xl" | Predefined label fontSize, checkbox width, height and border-radius |
spacing | number | "xs" | "sm" | "md" | "lg" | "xl" | Spacing between checkboxes in horizontal orientation |
value | string[] | Value of currently selected checkbox |
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 spread to InputWrapper |
Checkbox component Styles API
Name | Static selector | Description |
---|---|---|
root | .mantine-Checkbox-root | Root button element |
body | .mantine-Checkbox-body | Main element of checkbox |
inner | .mantine-Checkbox-inner | Includes input and label |
labelWrapper | .mantine-Checkbox-labelWrapper | Include label and description component |
input | .mantine-Checkbox-input | Checkbox input element |
icon | .mantine-Checkbox-icon | Checked or indeterminate state icon |
error | .mantine-Checkbox-error | Error message |
description | .mantine-Checkbox-description | Description |
label | .mantine-Checkbox-label | Label |