Skip to content

Commit 182f5bc

Browse files
authored
Fixes the disabled state for the Switch component (#1841)
1 parent 94c574b commit 182f5bc

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

apps/webapp/app/components/primitives/Switch.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { type ShortcutDefinition, useShortcutKeys } from "~/hooks/useShortcutKey
77

88
const small = {
99
container:
10-
"flex items-center h-[1.5rem] gap-x-1.5 rounded hover:bg-tertiary disabled:hover:bg-transparent pr-1 py-[0.1rem] pl-1.5 transition focus-custom disabled:hover:text-charcoal-400 disabled:opacity-50 text-charcoal-400 hover:text-charcoal-200 disabled:hover:cursor-not-allowed hover:cursor-pointer",
10+
"flex items-center h-[1.5rem] gap-x-1.5 rounded hover:bg-tertiary pr-1 py-[0.1rem] pl-1.5 hover:disabled:bg-charcoal-700 transition focus-custom disabled:opacity-50 text-text-dimmed hover:text-text-bright disabled:hover:cursor-not-allowed hover:cursor-pointer disabled:hover:text-rose-500",
1111
root: "h-3 w-6",
1212
thumb: "size-2.5 data-[state=checked]:translate-x-2.5 data-[state=unchecked]:translate-x-0",
1313
text: "text-xs text-text-dimmed",
@@ -28,7 +28,10 @@ const variations = {
2828
"group-data-[state=unchecked]:bg-charcoal-600 group-data-[state=unchecked]:group-hover:bg-charcoal-500/50"
2929
),
3030
thumb: small.thumb,
31-
text: cn(small.text, "transition group-hover:text-text-bright"),
31+
text: cn(
32+
small.text,
33+
"transition group-hover:text-text-bright group-disabled:group-hover:text-text-dimmed"
34+
),
3235
},
3336
};
3437

@@ -64,7 +67,12 @@ export const Switch = React.forwardRef<React.ElementRef<typeof SwitchPrimitives.
6467
ref={innerRef}
6568
>
6669
{label ? (
67-
<label className={cn("whitespace-nowrap", text)}>
70+
<label
71+
className={cn(
72+
"cursor-pointer whitespace-nowrap group-disabled:cursor-not-allowed",
73+
text
74+
)}
75+
>
6876
{typeof label === "string" ? <span>{label}</span> : label}
6977
</label>
7078
) : null}

0 commit comments

Comments
 (0)