useToggle vs useBoolean vs useDisclosure
Three ways to model open/closed UI. Pick based on API style and whether you need callbacks.
At a glance
useToggle
Tuple API. toggle() flips; toggle(true|false) sets. Great for compact flags.
useBoolean
Named helpers setTrue / setFalse / toggle. Explicit and readable in large files.
useDisclosure
Object API with open/close/toggle + optional onOpen/onClose. Best for dialogs/menus.
Pick when…
- useToggle — You want a one-liner boolean with flexible toggle(value?).
- useBoolean — Call sites should read as openFlag.setTrue().
- useDisclosure — Building modal/drawer/menu UI and may fire analytics on open/close.
Related library docs
Starter import
imports
import { useToggle } from '@/hooks';
import { useBoolean } from '@/hooks';
import { useDisclosure } from '@/hooks';