useBoolean
Generic boolean state with stable toggle, enable and disable actions.
Keeps on/off state without disclosure-specific ARIA. Values and functional updates are normalized to booleans; the initial value is also the server value.
Usage
Examples
Playground
API
1 option
2 return values
Accessibility
Use aria-pressed on toggle buttons or checked on switches. Use useDisclosure for a control that reveals a region.
Notes
- Covers the boolean useToggle use case with one API.
Related
useDisclosureOpen, close and toggle state for overlays and disclosures.useControllableStateState that works controlled or uncontrolled, like native inputs.useCountdownA pausable countdown or count-up that stops at its target.useCounterA number with increment, decrement, set and reset actions.useDebounceCallbackA debounced function with cancel and flush.useDebounceValueA value that updates only after it stops changing.