[material-ui][Radio] "No label associated with a form field" when using FormLabel
with RadioGroup
#40860
Labels
component: radio
This is the name of the generic UI component, not the React module!
docs
Improvements or additions to the documentation
package: material-ui
Specific to @mui/material
ready to take
Help wanted. Guidance available. There is a high chance the change will be accepted
Steps to reproduce
Link to live example: https://mui.com/material-ui/react-radio-button/
Current behavior
Chrome and Edge both complain in the "Issues" tab of page inspection "No label associated with a form field". Even the official demos in the above link result in these complaints.
Expected behavior
There shouldn't be any complaint.
To resolve this issue, I tried specifying "htmlFor" (as a
FormLabel
prop) and "id" (as aRadioGroup
prop). Chrome then tells meIncorrect use of <label for=FORM_ELEMENT>
(see screenshot)Context
I want to remove the warning, as well as learn how to properly use the
FormLabel
component.How does
FormLabel
work? How do I specify which component the label is for?Your environment
System:
OS: Windows 11 10.0.22621
Binaries:
Node: 20.11.0 - C:\Program Files\nodejs\node.EXE
npm: 10.4.0 - C:\Program Files\nodejs\npm.CMD
pnpm: Not Found
Browsers:
Chrome: Not Found
Edge: Chromium (121.0.2277.83)
npmPackages:
@mui/envinfo: ^2.0.16 => 2.0.16
Search keywords: FormLabel, RadioGroup, missing label
The text was updated successfully, but these errors were encountered: