-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathcheckbox.tsx
More file actions
41 lines (37 loc) · 1.21 KB
/
checkbox.tsx
File metadata and controls
41 lines (37 loc) · 1.21 KB
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
35
36
37
38
39
40
41
import * as CheckboxPrimitive from '@radix-ui/react-checkbox'
import * as React from 'react'
import { cn } from '#app/utils/misc.tsx'
export type CheckboxProps = Omit<
React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>,
'type'
> & {
type?: string
}
const Checkbox = React.forwardRef<
React.ElementRef<typeof CheckboxPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>
>(({ className, ...props }, ref) => (
<CheckboxPrimitive.Root
ref={ref}
className={cn(
'peer h-4 w-4 shrink-0 rounded-sm border-2 border-red-500 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground',
className,
)}
{...props}
>
<CheckboxPrimitive.Indicator
className={cn('flex items-center justify-center text-current')}
>
<svg viewBox="0 0 8 8">
<path
d="M1,4 L3,6 L7,2"
stroke="currentcolor"
strokeWidth="1"
fill="none"
/>
</svg>
</CheckboxPrimitive.Indicator>
</CheckboxPrimitive.Root>
))
Checkbox.displayName = CheckboxPrimitive.Root.displayName
export { Checkbox }