Both controls used `bg-muted` / `bg-background` for unchecked / thumb which collapse to the same hue as the surrounding card in dark mode, making them effectively invisible. - Switch: unchecked track now bg-input (light) / bg-muted-foreground/25 (dark) with a shadow-inner; thumb uses bg-card (light) / bg-foreground/95 (dark) so it pops in both states. - Checkbox: explicit bg-card + hover:border-border/80; slightly larger radius (5px) for visual rhythm with the rest of the surface.
31 lines
1.3 KiB
TypeScript
31 lines
1.3 KiB
TypeScript
import * as React from 'react';
|
|
import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
|
|
import { Check, Minus } from 'lucide-react';
|
|
import { cn } from '../lib/cn';
|
|
|
|
const Checkbox = React.forwardRef<
|
|
React.ElementRef<typeof CheckboxPrimitive.Root>,
|
|
React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>
|
|
>(({ className, ...props }, ref) => (
|
|
<CheckboxPrimitive.Root
|
|
ref={ref}
|
|
className={cn(
|
|
'peer size-4 shrink-0 rounded-[5px] border border-border bg-card shadow-xs transition-colors',
|
|
'hover:border-border/80',
|
|
'focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-ring/40',
|
|
'disabled:cursor-not-allowed disabled:opacity-50',
|
|
'data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground data-[state=checked]:border-primary',
|
|
'data-[state=indeterminate]:bg-primary data-[state=indeterminate]:text-primary-foreground data-[state=indeterminate]:border-primary',
|
|
className,
|
|
)}
|
|
{...props}
|
|
>
|
|
<CheckboxPrimitive.Indicator className="flex items-center justify-center text-current">
|
|
{props.checked === 'indeterminate' ? <Minus className="size-3" /> : <Check className="size-3" />}
|
|
</CheckboxPrimitive.Indicator>
|
|
</CheckboxPrimitive.Root>
|
|
));
|
|
Checkbox.displayName = 'Checkbox';
|
|
|
|
export { Checkbox };
|