Add helper text and error text components to RadioGroup and CheckboxGroup #3736
loicplaire
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Problem
The forms documentation demonstrates wrapping
RadioGroupandCheckboxGroupinFieldsetcomponents to provide helper text and error messages. However, this pattern creates several issues:1. Screen reader compatibility
Critical issue: When
aria-describedbyis set on the<fieldset>element (via Fieldset.Root), many screen readers (e.g. Voice Over) don't reliably announce the associated helper text and error messages. Screen readers expectaria-describedbyon the interactive group element (role="radiogroup"or the checkbox group container), not the fieldset wrapper.This renders as:
Better pattern:
aria-describedbyon theradiogroupelement ensures reliable announcements:2. Redundant semantics
RadioGroup.Rootalready renders withrole="radiogroup". Wrapping in<fieldset>creates double grouping semantics:Per WAI-ARIA APG, you should use either fieldset+legend or radiogroup+aria-labelledby, not both.
3. Inconsistency with Field pattern
Field works naturally for single controls:
But RadioGroup/CheckboxGroup feel forced with Fieldset:
4. API gaps
RadioGroup.HelperTextandRadioGroup.ErrorTextCheckbox.Grouphas no label component at all ❌Fieldsetwhich has the screen reader issuesProposed solution
Add helper text and error text components to RadioGroup and CheckboxGroup:
Benefits
Our current workaround
We have to use
Fieldset.Contextin templates to access fieldset IDs, then manually apply ARIA attributes to the inner group elements:This ensures screen readers announce the helper and error text, but requires this workaround for every wrapper component when we feel it should be part of Ark UI.
Keen to get more background information on the current architectural choices and the suggestions above.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions