useToggleState
Provides state management for toggle components like checkboxes and switches.
install | yarn add react-stately |
---|---|
version | 3.32.2 |
usage | import {useToggleState} from 'react-stately' |
API#
useToggleState(
(props: ToggleStateOptions
)): ToggleState
Interface#
Properties
Name | Type | Description |
isSelected | boolean | Whether the toggle is selected. |
Methods
Method | Description |
setSelected(
(isSelected: boolean
)): void | Updates selection state. |
toggle(): void | Toggle the selection state. |
Example#
See the docs for useCheckbox in react-aria for an example of useToggleState
.