UNPKG

struct-ui-components

Version:

A collection of reusable, customizable React components built with TypeScript, Tailwind CSS, and Storybook. Designed for modern UI development with flexibility and scalability.

14 lines (10 loc) 341 B
import { useState } from "react"; export const useToggle = (defaultValue: boolean) => { const [value, setValue] = useState<boolean>(defaultValue); const toggleValue = (value?: boolean) => { setValue((currentValue) => typeof value === "boolean" ? value : !currentValue, ); }; return [value, toggleValue] as const; };