Background
In T334514: ToggleSwitch: consider making the label required, we decided not to make the label required for binary inputs because it would be too limiting to Codex users. Instead, we will provide guidelines and warnings that steer Codex users in the right direction in terms of accessibility.
User Story
As a Codex user, I want to have flexibility in how I choose to label binary inputs while still being guided down the correct path for accessibility requirements.
Acceptance Criteria
For the Checkbox, Radio, and ToggleSwitch components:
- Add guidelines in the Figma spec that make it clear a semantic label should be provided somewhere.
- Throw a warning to the developer when the default (label) slot is empty that goes away if aria-label or aria-labelledby attributes are present.
- Add documentation about these guidelines and the above warning in the docs for each component.
- Update all examples of ToggleSwitches to show the different kinds of labelling options that conform to the guidelines.