RadioGroup / Checkbox disabled label via :has()
Version: 0.2.0 ยท Type: ๐ Bug Fix
Problemโ
When label is passed to RadioGroupItem / Checkbox, the disabled state only grayed out the control itself (the circle / box), while the label text stayed normal black and the cursor was not not-allowed, making the visuals inconsistent.
There were two layers to the root cause:
- The label row container only declared
data-disabled:cursor-not-allowed, with no disabled-state text color. - More importantly: the label's disabled state originally relied on the
data-disabledthat the component manually set on<label>(sourced from the item's owndisabledprop). But whendisabledis set at the RadioGroup group level, an individual item does not receive that prop, so<label>carries nodata-disabled, and the entiredata-disabled:*rule set fails to match โ neither the cursor nor the text color take effect. Radix, meanwhile, still setsdata-disabledon the internal radio button.
Changed Filesโ
packages/design/src/components/RadioGroup/styles.tspackages/design/src/components/Checkbox/styles.tspackages/design/src/components/RadioGroup/RadioGroup.test.tsxpackages/design/src/components/Checkbox/Checkbox.test.tsx
Changesโ
- The disabled state of
RADIO_LABEL_CLASS/CHECKBOX_LABEL_CLASSis changed to be driven by:has([data-disabled]):has-[[data-disabled]]:cursor-not-allowed+has-[[data-disabled]]:text-(--Labels-Disabled). Since Radix setsdata-disabledon the internal control for both item-level and group-level disabling, the whole-row disabled state is inferred from that, so both disable sources correctly gray out (text degrades toLabels/Disabled#A3A3A3). - Consistent with the disabled-text convention of components like Button (unified
--Labels-Disabled). - Both components keep the manual
data-disabledon<label>(item-level semantic marker), but the styling no longer depends on it. - Tests: assert the label carries the
has-[[data-disabled]]:*classes and the internal control carriesdata-disabled; RadioGroup adds a group-level disabled case (an item without adisabledprop can still be inferred).
Notesโ
- RadioGroup: parent DES-95 / child DES-115 RadioGroup: disabled label via :has()
- Checkbox: parent DES-94 / child DES-116 Checkbox: disabled label via :has()