ShadCN-Inspired Tailwind Checkbox Component
DSy lets you build checkboxes in real time — adjust size, style, and default/checked states. Copy React/Next.js code.
NOTE: It's UI-only - no validation, connect to any form system.
Install dependency below to use component
npm install @radix-ui/react-checkbox
'use client';
import * as React from 'react';
import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
import { Check } from 'lucide-react';
import { cn } from '@/lib/utils';
const Checkbox = React.forwardRef<
React.ElementRef<typeof CheckboxPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>
>(
({ className, ...props }, ref): React.JSX.Element => {
return (
<CheckboxPrimitive.Root
ref={ref}
className={cn(
'peer shrink-0 border bg-transparent 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',
'border-gray-500',
'data-[state=checked]:bg-white',
'data-[state=checked]:text-blue-600',
'rounded-sm',
'size-4',
className
)}
{...props}>
<CheckboxPrimitive.Indicator
className={cn('flex items-center justify-center text-current')}>
<Check className={cn('size-4')}/>
</CheckboxPrimitive.Indicator>
</CheckboxPrimitive.Root>
);
}
);
Checkbox.displayName = CheckboxPrimitive.Root.displayName;
export { Checkbox };Border Radius
Adjust corner roundness16px