useCheckboxGroupState
Provides state management for a checkbox group component. Provides a name for the group, and manages selection and focus state.
| install | yarn add @react-stately/checkbox |
|---|---|
| version | 3.0.3 |
| usage | import {useCheckboxGroupState} from '@react-stately/checkbox' |
API#
useCheckboxGroupState(
(props: CheckboxGroupProps
)): CheckboxGroupStateInterface#
Properties
| Name | Type | Description |
value | | Current selected values. |
isDisabled | boolean | Whether the checkbox group is disabled. |
isReadOnly | boolean | Whether the checkbox group is read only. |
Methods
| Method | Description |
isSelected(
(value: string
)): boolean | Returns whether the given value is selected. |
setValue(
(value: string[]
)): void | Sets the selected values. |
addValue(
(value: string
)): void | Adds a value to the set of selected values. |
removeValue(
(value: string
)): void | Removes a value from the set of selected values. |
toggleValue(
(value: string
)): void | Toggles a value in the set of selected values. |
| Name | Type | Description |
value | string[] | The current value (controlled). |
defaultValue | string[] | The default value (uncontrolled). |
onChange | (
(value: T
)) => void | Handler that is called when the value changes. |
isDisabled | boolean | Whether the input is disabled. |
isReadOnly | boolean | Whether the input can be selected but not changed by the user. |
label | ReactNode | The content to display as the label. |
Properties
| Name | Type | Description |
value | | Current selected values. |
isDisabled | boolean | Whether the checkbox group is disabled. |
isReadOnly | boolean | Whether the checkbox group is read only. |
Methods
| Method | Description |
isSelected(
(value: string
)): boolean | Returns whether the given value is selected. |
setValue(
(value: string[]
)): void | Sets the selected values. |
addValue(
(value: string
)): void | Adds a value to the set of selected values. |
removeValue(
(value: string
)): void | Removes a value from the set of selected values. |
toggleValue(
(value: string
)): void | Toggles a value in the set of selected values. |