25 lines
825 B
TypeScript
25 lines
825 B
TypeScript
"use client";
|
|
|
|
import * as React from "react";
|
|
import * as SwitchPrimitives from "@radix-ui/react-switch";
|
|
|
|
import { cn } from "@/lib/utils";
|
|
|
|
const Switch = ({ className, ...props }: SwitchPrimitives.SwitchProps) => (
|
|
<SwitchPrimitives.Root
|
|
className={cn(
|
|
"peer inline-flex h-6 w-11 shrink-0 cursor-pointer border-2 border-foreground items-center disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary",
|
|
className,
|
|
)}
|
|
{...props}
|
|
>
|
|
<SwitchPrimitives.Thumb
|
|
className={cn(
|
|
"pointer-events-none block h-4 w-4 bg-primary border-2 mx-0.5 border-foreground ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0 data-[state=checked]:bg-background",
|
|
)}
|
|
/>
|
|
</SwitchPrimitives.Root>
|
|
);
|
|
|
|
export { Switch };
|