Migration in progress
This page is still being migrated to our new website. In the meantime, you can explore the new React Aria Components docs here.
useToggleState
Provides state management for toggle components like checkboxes and switches.
useToggleState(
(props: ToggleStateOptions
)): ToggleState
Properties
| Name | Type | Description |
isSelected | boolean | Whether the toggle is selected. |
defaultSelected | boolean | Whether the toggle is selected by default. |
Methods
| Method | Description |
setSelected(
(isSelected: boolean
)): void | Updates selection state. |
toggle(): void | Toggle the selection state. |
See the docs for useCheckbox in react-aria for an example of useToggleState.