mui / mui/material-ui

[TextField] Problems with changing the input label fontSize

Open
#31,146 6 comments 11 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

scope: text field type: bug
Dominant language
JavaScript
Stars
99.1k
Forks
32.5k
Avg merge
2d 17h
Merged PRs (30d)
106

Description

I tried to change the fontsize of the lable using

const theme = createTheme({
  components: {
    MuiInputLabel: {
      defaultProps: {
        sx: {
          fontSize: "13px",
        },
      },
    },
  },
});

Achieved
image

But On focusing the fontsize appears too small which make a empty space on the right (Look into pic below)
Screenshot 2022-02-19 at 5 33 47 PM

Please let me know how can I get Rid of it.
Or I can change the Font size only when the input is not focused.
What I wanted it to look like is
image (Small font size when Field is empty)
and
image (Normal font size when Field is Filled)

Originally posted by @iamadityaaz in https://github.com/mui/material-ui/issues/13840#issuecomment-1046002798

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 MuiInputLabel defaultProps and sx configuration shown in the issue, then inspect the TextField label behavior in its focused and filled states. Done means the label has the requested font size in each state without the unwanted empty space shown in the screenshots.

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-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.