Accessibility: EmptySwatch must have an accessible name via aria-label, Tooltip, aria-labelledby, etc. (@microsoft/fluentui-jsx-a11y/emptyswatch-needs-labelling)
💼 This rule is enabled in the ✅ recommended config.
All interactive elements must have an accessible name.
EmptySwatch without a supported label lacks an accessible name for assistive technology users.
- ✅
aria-labelonEmptySwatch - ✅
aria-labelledbyonEmptySwatch - ✅
htmlFor/id(native<label htmlFor="…">↔id="…"onEmptySwatch) - ✅ Wrapping native
<label>…</label> - ✅
Tooltipparent withrelationship="label" - ✅ Text content child (e.g.,
<EmptySwatch>None</EmptySwatch>) - ❌
Fieldparent (not allowed forEmptySwatch) - ❌ Container-only label (e.g., only the surrounding
SwatchPickeris labelled)
- Add
aria-label/aria-labelledbytoEmptySwatch. - Use
<label htmlFor="…">+id="…"onEmptySwatch. - Wrap in a native
<label>orTooltip (relationship="label"). - Provide meaningful text as the child of
EmptySwatch.
This rule ensures EmptySwatch is labelled using allowed mechanisms.
// No label
<SwatchPicker>
<EmptySwatch value="none" />
</SwatchPicker>// Container-only label: EmptySwatch itself is unnamed
<SwatchPicker aria-label="Color picker">
<EmptySwatch value="none" />
</SwatchPicker>// Not allowed: Field parent labelling
<SwatchPicker>
<Field label="No color">
<EmptySwatch value="none" />
</Field>
</SwatchPicker>// aria-label
<SwatchPicker>
<EmptySwatch value="none" aria-label="No color" />
</SwatchPicker>// aria-labelledby
<>
<span id="empty-no-color">No color</span>
<SwatchPicker>
<EmptySwatch value="none" aria-labelledby="empty-no-color" />
</SwatchPicker>
</>// htmlFor/id
<>
<label htmlFor="empty-none">No color</label>
<SwatchPicker>
<EmptySwatch id="empty-none" value="none" />
</SwatchPicker>
</>// Wrapping native <label>
<label>
No color
<EmptySwatch value="none" />
</label>// Tooltip (acts as a label)
<SwatchPicker>
<Tooltip relationship="label" content="No color">
<EmptySwatch value="none" />
</Tooltip>
</SwatchPicker>// Text content child
<SwatchPicker>
<EmptySwatch value="none">No color</EmptySwatch>
</SwatchPicker>