useToggle
A hook to toggle a value
Installation
npx shadcn@latest add @shadcnhooks/use-toggleAPI
/**
* A hook to toggle a value
* @param defaultValue - The default value of the value
* @param reverseValue - The reverse value of the value
* @returns The value and the actions to toggle the value
*/
function useToggle<T = boolean>(): [boolean, Actions<T>]
function useToggle<T>(defaultValue: T): [T, Actions<T>]
function useToggle<T, U>(
defaultValue: T,
reverseValue: U,
): [T | U, Actions<T | U>]Credits
Last updated on