forked from Weaverse/pilot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
checkbox.tsx
34 lines (31 loc) · 1.2 KB
/
checkbox.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
import * as React from "react";
import { cn } from "~/lib/cn";
import { IconCheck } from "./icons";
interface CheckboxProps
extends React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root> {
label?: string;
}
const Checkbox = React.forwardRef<
React.ElementRef<typeof CheckboxPrimitive.Root>,
CheckboxProps
>(({ className, label, ...props }, ref) => (
<div className={cn("flex items-center space-x-2.5", className)}>
<CheckboxPrimitive.Root
ref={ref}
className={cn(
"peer w-5 h-5 shrink-0 border ring-offset-background focus-visible:outline-none focus-visible:ring focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-background data-[state=checked]:text-body",
)}
{...props}
>
<CheckboxPrimitive.Indicator
className={cn("flex items-center justify-center text-current")}
>
<IconCheck className="h-3 w-3" />
</CheckboxPrimitive.Indicator>
</CheckboxPrimitive.Root>
{label ? <span>{label}</span> : null}
</div>
));
Checkbox.displayName = CheckboxPrimitive.Root.displayName;
export { Checkbox };