"use client";
import { useCallback, useState } from "react";
/**
 * @example Simple Example
 * ```tsx
 * import { Button } from "@react-md/core/button/Button";
 * import { useToggle } from "@react-md/core/useToggle";
 * import { type ReactElement } from "react";
 *
 * function Example(): ReactElement {
 *   const { toggled, toggle } = useToggle();
 *
 *   return (
 *     <>
 *       <Button onClick={toggle}>Toggle</Button>
 *       {`Toggled: ${toggled}`}
 *     </>
 *   );
 * }
 * ```
 *
 * @param defaultValue - `false`
 */ export function useToggle(defaultValue = false) {
    const [toggled, setToggled] = useState(defaultValue);
    return {
        toggled,
        setToggled,
        toggle: useCallback(()=>{
            setToggled((prevToggled)=>!prevToggled);
        }, []),
        enable: useCallback(()=>{
            setToggled(true);
        }, []),
        disable: useCallback(()=>{
            setToggled(false);
        }, [])
    };
}

//# sourceMappingURL=useToggle.js.map