| 12345678910111213141516171819202122232425262728293031 |
- "use client"
- import * as React from "react"
- import * as CheckboxPrimitive from "@radix-ui/react-checkbox"
- import { Check, Minus } from "lucide-react"
- import { cn } from "@/lib/utils"
- const Checkbox = React.forwardRef<
- React.ElementRef<typeof CheckboxPrimitive.Root>,
- React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root> & { indeterminate?: boolean }
- >(({ className, indeterminate, checked, ...props }, ref) => (
- <CheckboxPrimitive.Root
- ref={ref}
- className={cn(
- "grid place-content-center peer h-4 w-4 shrink-0 rounded-sm border border-input focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:border-primary data-[state=checked]:text-primary-foreground data-[state=indeterminate]:bg-primary data-[state=indeterminate]:border-primary data-[state=indeterminate]:text-primary-foreground",
- className
- )}
- checked={indeterminate ? 'indeterminate' : checked}
- {...props}
- >
- <CheckboxPrimitive.Indicator
- className={cn("grid place-content-center text-current")}
- >
- {indeterminate ? <Minus className="h-3.5 w-3.5" /> : <Check className="h-4 w-4" />}
- </CheckboxPrimitive.Indicator>
- </CheckboxPrimitive.Root>
- ))
- Checkbox.displayName = CheckboxPrimitive.Root.displayName
- export { Checkbox }
|