diff --git a/src/components/ui/switch.tsx b/src/components/ui/switch.tsx new file mode 100644 index 0000000..4c02678 --- /dev/null +++ b/src/components/ui/switch.tsx @@ -0,0 +1,31 @@ +import * as React from "react"; +import { cn } from "@/lib/utils"; + +export interface SwitchProps extends Omit, "onChange"> { + checked?: boolean; + defaultChecked?: boolean; + onCheckedChange?: (checked: boolean) => void; +} + +export const Switch = ({ className, checked: controlled, defaultChecked, onCheckedChange, ...props }: SwitchProps) => { + const [internal, setInternal] = React.useState(!!defaultChecked); + const checked = controlled ?? internal; + return ( + + ); +}; + +export default Switch;