mui / mui/material-ui

[material-ui][Radio] "No label associated with a form field" when using `FormLabel` with `RadioGroup`

Open
#40,860 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

docs scope: radio
Dominant language
JavaScript
Stars
99.1k
Forks
32.5k
Avg merge
2d 17h
Merged PRs (30d)
106

Description

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 a RadioGroup prop). Chrome then tells me Incorrect use of <label for=FORM_ELEMENT> (see screenshot)

image

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Material UI Radio demo at https://mui.com/material-ui/react-radio-button/ and reproduce the warning in Chrome or Edge. Read the FormLabel and RadioGroup usage shown there, then verify that the example no longer reports an unassociated label or incorrect label target and that the proper association is clear to users.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
accessibility, frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.