fix(ui): dark-mode Switch + Checkbox visibility

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.
This commit is contained in:
DrSmoothl committed 2026-05-17 14:11:29 +08:00
1 parent 3e943e8f0d
commit 8a94188dc6
2 files changed
+13 -7

No files matched your search

+3 -2
View File
@@ -10,12 +10,13 @@ const Checkbox = React.forwardRef<
<CheckboxPrimitive.Root
ref={ref}
className={cn(
'peer size-4 shrink-0 rounded-[4px] border border-border bg-transparent shadow-xs transition-colors',
'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
className,
)}
{...props}
>
+10 -5
View File
@@ -9,18 +9,23 @@ const Switch = React.forwardRef<
<SwitchPrimitive.Root
ref={ref}
className={cn(
'peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors',
'peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border border-border shadow-inner transition-colors',
'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=unchecked]:bg-muted',
className
// Checked: filled with primary
'data-[state=checked]:bg-primary data-[state=checked]:border-primary',
// Unchecked: visible track that contrasts with both surface modes
'data-[state=unchecked]:bg-input dark:data-[state=unchecked]:bg-muted-foreground/25',
className,
)}
{...props}
>
<SwitchPrimitive.Thumb
className={cn(
'pointer-events-none block size-4 rounded-full bg-background shadow-sm ring-0 transition-transform',
'data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0'
'pointer-events-none block size-4 rounded-full shadow-md ring-0 transition-transform',
// Thumb always uses card surface so it pops against the track in both states.
'bg-card dark:bg-foreground/95',
'data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0',
)}
/>
</SwitchPrimitive.Root>