返回 presentation-ai
checkbox.tsx
根目录 / src / components / ui / checkbox.tsx
1 "use client";
2
3 import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
4 import { Check } from "lucide-react";
5 import * as React from "react";
6
7 import { cn } from "@/lib/utils";
8
9 const Checkbox = React.forwardRef<
10 React.ElementRef<typeof CheckboxPrimitive.Root>,
11 React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>
12 >(({ className, ...props }, ref) => (
13 <CheckboxPrimitive.Root
14 ref={ref}
15 className={cn(
16 "peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:outline-hidden disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
17 className,
18 )}
19 {...props}
20 >
21 <CheckboxPrimitive.Indicator
22 className={cn("flex items-center justify-center text-current")}
23 >
24 <Check className="h-4 w-4" />
25 </CheckboxPrimitive.Indicator>
26 </CheckboxPrimitive.Root>
27 ));
28 Checkbox.displayName = CheckboxPrimitive.Root.displayName;
29
30 export { Checkbox };
31
31 lines Plain Text