Skip to content
GaudiGaudi Design System home

Search documentation

Search every page, heading and paragraph.

useBoolean

Generic boolean state with stable toggle, enable and disable actions.

HooksState@gaudi/design-system/hooks/state/use-booleanView in StorybookSource

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

import { useBoolean } from '@gaudi/design-system/hooks';
const { value, toggle, setTrue, setFalse } = useBoolean(false);

Examples

Playground

Storybook

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.