@@ -33,7 +33,10 @@ export const Switch = ({
3333 const hasLabel = label != null && label !== '' ;
3434
3535 return (
36- < div className = "group/switch flex items-center gap-2" >
36+ < div
37+ className = "group/switch flex items-center gap-2"
38+ data-state = { checked ? 'checked' : 'unchecked' }
39+ >
3740 { ( labelPosition === 'left' || labelPosition === 'both' ) && hasLabel && (
3841 < SwitchLabel
3942 id = { id }
@@ -101,7 +104,7 @@ interface LabelProps {
101104
102105function SwitchLabel ( { id, label, size = 'medium' , state, loading } : LabelProps ) {
103106 const baseClass =
104- 'group-has- data-disabled/switch:[&:not([data-loading])]:text-contrast-400 font-semibold select-none' ;
107+ 'group-data-[ disabled] /switch:[&:not([data-loading])]:text-contrast-400 font-semibold select-none' ;
105108 const sizeClass = {
106109 small : 'text-sm' ,
107110 medium : 'text-base' ,
@@ -136,7 +139,7 @@ function SwitchLabel({ id, label, size = 'medium', state, loading }: LabelProps)
136139 < div className = "leading-[0]" >
137140 < label
138141 className = { clsx (
139- 'group-has-data-[state=checked]/switch:block group-has- data-[state=unchecked]/switch:invisible mb-[-2px] leading-[0] ' ,
142+ 'mb-[-2px] leading-[0] group-data-[state=unchecked]/switch:invisible group-data-[state=checked]/switch:block ' ,
140143 baseClass ,
141144 sizeClass ,
142145 ) }
@@ -147,7 +150,7 @@ function SwitchLabel({ id, label, size = 'medium', state, loading }: LabelProps)
147150 </ label >
148151 < label
149152 className = { clsx (
150- 'group-has- data-[state=checked]/switch:invisible group-has- data-[state=unchecked]/switch:block mt-[-1px] leading-[0] ' ,
153+ 'mt-[-1px] leading-[0] group- data-[state=checked]/switch:invisible group-data-[state=unchecked]/switch:block' ,
151154 baseClass ,
152155 sizeClass ,
153156 ) }
0 commit comments