string
Checkbox
Checkbox component is used in forms when a user needs to select multiple values from several options.
Props#
Checkbox Props#
aria-describedby
aria-describedby
aria-invalid
aria-invalid
true
aria-label
aria-label
Defines the string that labels the checkbox element.
string
aria-labelledby
aria-labelledby
Refers to the id
of the element that labels the checkbox element.
string
colorScheme
colorScheme
"whiteAlpha" | "blackAlpha" | "gray" | "red" | "orange" | "yellow" | "green" | "teal" | "blue" | "cyan" | "purple" | "pink" | "linkedin" | "facebook" | "messenger" | "whatsapp" | "twitter" | "telegram"
"blue"
icon
icon
The checked icon to use
React.ReactElement
CheckboxIcon
iconColor
iconColor
The color of the checkbox icon when checked or indeterminate
string
iconSize
iconSize
The size of the checkbox icon when checked or indeterminate
string | number
id
id
id assigned to input
string
inputProps
inputProps
Additional props to be forwarded to the input
element
InputHTMLAttributes<HTMLInputElement>
isChecked
isChecked
If true
, the checkbox will be checked.
You'll need to pass onChange
to update its value (since it is now controlled)
boolean
isDisabled
isDisabled
If true
, the checkbox will be disabled
boolean
isFocusable
isFocusable
If true
and isDisabled
is passed, the checkbox will
remain tabbable but not interactive
boolean
isIndeterminate
isIndeterminate
If true
, the checkbox will be indeterminate.
This only affects the icon shown inside checkbox
and does not modify the isChecked property.
boolean
isInvalid
isInvalid
If true
, the checkbox is marked as invalid.
Changes style of unchecked state.
boolean
isReadOnly
isReadOnly
If true
, the checkbox will be readonly
boolean
isRequired
isRequired
If true
, the checkbox input is marked as required,
and required
attribute will be added
boolean
name
name
The name of the input field in a checkbox (Useful for form submission).
string
onChange
onChange
The callback invoked when the checked state of the Checkbox
changes.
((event: ChangeEvent<HTMLInputElement>) => void)
onFocus
onFocus
The callback invoked when the checkbox is focused
((event: FocusEvent<HTMLInputElement, Element>) => void)
size
size
"sm" | "md" | "lg"
"md"
spacing
spacing
The spacing between the checkbox and its label text
SystemProps["marginLeft"]
0.5rem
tabIndex
tabIndex
The tab-index property of the underlying input element.
number
value
value
The value to be used in the checkbox input. This is the value that will be returned on form submission.
string | number
variant
variant
Variants for Checkbox
are not implemented in the default theme. You can extend the theme to implement them.
string
CheckboxGroup Props#
colorScheme
colorScheme
Color Schemes for CheckboxGroup
are not implemented in the default theme. You can extend the theme to implement them.
string
defaultValue
defaultValue
The initial value of the checkbox group
(string | number)[]
isDisabled
isDisabled
If true
, all wrapped checkbox inputs will be disabled
boolean
isNative
isNative
If true
, input elements will receive
checked
attribute instead of isChecked
.
This assumes, you're using native radio inputs
boolean
onChange
onChange
The callback fired when any children Checkbox is checked or unchecked
((value: (string | number)[]) => void)
size
size
Sizes for CheckboxGroup
are not implemented in the default theme. You can extend the theme to implement them.
string
value
value
The value of the checkbox group
(string | number)[]
variant
variant
Variants for CheckboxGroup
are not implemented in the default theme. You can extend the theme to implement them.
string
Shared Style Props#
The following style props can be set on CheckboxGroup
and they will be
forwarded to all children Checkbox
components.
Name | Type | Default | Description |
---|---|---|---|
colorScheme | string | The color of the checkbox when it is checked. This should be one of the color keys in the theme (e.g."green", "red"). | |
children | React.ReactNode | The content of the checkbox group. | |
size | sm , md , lg | md | The size of the checkbox. |
variant | string | The variant of the checkbox. |
Props#
Checkbox Props#
aria-describedby
aria-describedby
string
aria-invalid
aria-invalid
true
aria-label
aria-label
Defines the string that labels the checkbox element.
string
aria-labelledby
aria-labelledby
Refers to the id
of the element that labels the checkbox element.
string
colorScheme
colorScheme
"whiteAlpha" | "blackAlpha" | "gray" | "red" | "orange" | "yellow" | "green" | "teal" | "blue" | "cyan" | "purple" | "pink" | "linkedin" | "facebook" | "messenger" | "whatsapp" | "twitter" | "telegram"
"blue"
icon
icon
The checked icon to use
React.ReactElement
CheckboxIcon
iconColor
iconColor
The color of the checkbox icon when checked or indeterminate
string
iconSize
iconSize
The size of the checkbox icon when checked or indeterminate
string | number
id
id
id assigned to input
string
inputProps
inputProps
Additional props to be forwarded to the input
element
InputHTMLAttributes<HTMLInputElement>
isChecked
isChecked
If true
, the checkbox will be checked.
You'll need to pass onChange
to update its value (since it is now controlled)
boolean
isDisabled
isDisabled
If true
, the checkbox will be disabled
boolean
isFocusable
isFocusable
If true
and isDisabled
is passed, the checkbox will
remain tabbable but not interactive
boolean
isIndeterminate
isIndeterminate
If true
, the checkbox will be indeterminate.
This only affects the icon shown inside checkbox
and does not modify the isChecked property.
boolean
isInvalid
isInvalid
If true
, the checkbox is marked as invalid.
Changes style of unchecked state.
boolean
isReadOnly
isReadOnly
If true
, the checkbox will be readonly
boolean
isRequired
isRequired
If true
, the checkbox input is marked as required,
and required
attribute will be added
boolean
name
name
The name of the input field in a checkbox (Useful for form submission).
string
onChange
onChange
The callback invoked when the checked state of the Checkbox
changes.
((event: ChangeEvent<HTMLInputElement>) => void)
onFocus
onFocus
The callback invoked when the checkbox is focused
((event: FocusEvent<HTMLInputElement, Element>) => void)
size
size
"sm" | "md" | "lg"
"md"
spacing
spacing
The spacing between the checkbox and its label text
SystemProps["marginLeft"]
0.5rem
tabIndex
tabIndex
The tab-index property of the underlying input element.
number
value
value
The value to be used in the checkbox input. This is the value that will be returned on form submission.
string | number
variant
variant
Variants for Checkbox
are not implemented in the default theme. You can extend the theme to implement them.
string
CheckboxGroup Props#
colorScheme
colorScheme
Color Schemes for CheckboxGroup
are not implemented in the default theme. You can extend the theme to implement them.
string
defaultValue
defaultValue
The initial value of the checkbox group
(string | number)[]
isDisabled
isDisabled
If true
, all wrapped checkbox inputs will be disabled
boolean
isNative
isNative
If true
, input elements will receive
checked
attribute instead of isChecked
.
This assumes, you're using native radio inputs
boolean
onChange
onChange
The callback fired when any children Checkbox is checked or unchecked
((value: (string | number)[]) => void)
size
size
Sizes for CheckboxGroup
are not implemented in the default theme. You can extend the theme to implement them.
string
value
value
The value of the checkbox group
(string | number)[]
variant
variant
Variants for CheckboxGroup
are not implemented in the default theme. You can extend the theme to implement them.
string
Shared Style Props#
The following style props can be set on CheckboxGroup
and they will be
forwarded to all children Checkbox
components.
Name | Type | Default | Description |
---|---|---|---|
colorScheme | string | The color of the checkbox when it is checked. This should be one of the color keys in the theme (e.g."green", "red"). | |
children | React.ReactNode | The content of the checkbox group. | |
size | sm , md , lg | md | The size of the checkbox. |
variant | string | The variant of the checkbox. |