useToggleState

Provides state management for toggle components like checkboxes and switches.

installyarn add @react-stately/toggle
version3.0.0-rc.2
usageimport {useToggleState} from '@react-stately/toggle'

API#


useToggleState( (props: CheckboxBase )): ToggleState

Interface#


NameTypeDescription
isSelectedbooleanWhether the toggle is selected.
setSelected( (isSelected: boolean )) => voidUpdates selection state.

Example#


See the docs for useCheckbox in react-aria for an example of useToggleState.