useBoolean
A hook to toggle a boolean value
Loading...
Installation
npx shadcn@latest add @shadcnhooks/use-booleanAPI
/**
* A hook to toggle a boolean value
* @param defaultValue - The default value of the boolean
*/
export function useBoolean(defaultValue?: boolean): readonly [
boolean,
{
/**
* Set the value of the boolean
* @param value - The value to set the boolean to
*/
set: (value: boolean) => void
/**
* Set the value of the boolean to true
*/
setTrue: () => void
/**
* Set the value of the boolean to false
*/
setFalse: () => void
/**
* Toggle the value of the boolean
*/
toggle: () => void
},
]Credits
Last updated on