Hooks/State Management/useBoolean

useBoolean

A custom React hook to manage boolean state with toggle functionality.

Example

Loading...

Install

npx shadcn@latest add https://unlogg.com/r/use-boolean.json
pnpm dlx shadcn@latest add https://unlogg.com/r/use-boolean.json
bunx shadcn@latest add https://unlogg.com/r/use-boolean.json

Notes

  • Provides a simple way to manage boolean state with built-in toggle functionality.
  • Includes functions to set the state to true, false, or toggle the current state

API Reference

Parameters

PropTypeDefault
defaultValue?
boolean
false

Returns

PropTypeDefault
toggle?
() => void
-
setFalse?
() => void
-
setTrue?
() => void
-
setValue?
React.Dispatch<React.SetStateAction<boolean>>
-
value?
boolean
-