mui / mui/material-ui

[FormControl] Form Label not respecting the color prop

Open
#32,274 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

component: FormControl scope: system type: new feature
Dominant language
JavaScript
Stars
99.1k
Forks
32.5k
Avg merge
2d 17h
Merged PRs (30d)
106

Description

https://github.com/mui/material-ui/blob/47460ce5538c6e6e4e0edb4fe31560dd00ed6e07/packages/mui-material/src/FormLabel/FormLabel.js#L41

Trying to review my labels and I came across this one. No matter what I set my InputLabel color prop to be the text remains text.secondary.

<InputLabel shrink={false} disableAnimation={true} color="primary">Foo Bar</InputLabel>

Given my text.primary color is set to red and my text.secondary is set to green. I see a correct class name being generated for 'MuiFormLabel-colorSecondary' but the composed color isn't being taken into account. See screen shots as examples.

In this given example (https://codesandbox.io/s/silent-monad-v0gih7?file=/src/App.tsx)
The input label is green despite giving it the color as primary. I can override with an sx prop for color, but I would expect the component to use the theme palette color as described in the documents.

Screen Shot 2022-04-12 at 2 17 54 PM

Screen Shot 2022-04-12 at 2 17 40 PM

I'm happy to work on a solution if no one has the time to check this out.

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 linked FormLabel.js line and reproduce the issue using the provided CodeSandbox, setting InputLabel color="primary" with distinct text.primary and text.secondary theme colors. Trace why the generated color class does not affect the rendered text; done means the label uses the theme palette color requested by its color prop.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.