BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/shadcn-hooks/use-boolean

use-boolean

shadcn-hooks/use-boolean
FreeHook

A hook to toggle a boolean value

Install it

npx shadcn@latest add https://shadcn-hooks.com/r/use-boolean.json

Source

registry/hooks/use-boolean.tsshadcn-hooks.com/r/use-boolean.json
1import { useMemo } from 'react'
2import useToggle from '@/registry/hooks/use-toggle'
3
4export function useBoolean(defaultValue: boolean = false) {
5 const [state, actions] = useToggle(defaultValue)
6
7 return [
8 state,
9 useMemo(
10 () => ({
11 set: (value: boolean) => actions.set(value),
12 setTrue: () => actions.set(true),
13 setFalse: () => actions.set(false),
14 toggle: () => actions.toggle(),
15 }),
16 [actions],
17 ),
18 ] as const
19}

What it pulls in

Other registry items

  • @shadcnhooks/use-toggle

Files it writes

  • registry/hooks/use-boolean.ts

Facts

Registry
shadcn-hooks
Type
registry:hook
Access
Free
Files written
1
Licence
the repository states none
First indexed
2026-08-03
Last confirmed
yesterday

Go to the source

shadcn-hooks.com Debbl/shadcn-hooks on GitHub Raw registry item This item as JSON

More from shadcn-hooks

All 58 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
use-active-elementuse-active-elementshadcn-hooksHooksFreeno deps
use-batteryuse-batteryshadcn-hooksHooksFreeno deps
use-click-any-whereuse-click-any-whereshadcn-hooksHooksFreeno deps
use-click-awayuse-click-awayshadcn-hooksHooksFreeno deps
use-clipboarduse-clipboardshadcn-hooksHooksFreeno deps
use-controllable-valueuse-controllable-valueshadcn-hooksHooksFree1 dep
use-counteruse-countershadcn-hooksHooksFreeno deps
use-creationuse-creationshadcn-hooksHooksFree1 dep
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex