I would like to be able to change the label fontSize from the material ui TextField component. I’ve come up with the InputLabelProps which works great, but as you can see in the picture bellow the label is too squeezy when focused
Here is my implementation of the TextField
<TextField {...params} InputLabelProps={{
style : {color: '#518eb9', fontSize: 18, fontWeight: 1000}
}} label="Hovedkategori" />
I’ve found out that the label displayed when focused actually comes from another tag:
<legend class="css-1ftyaf0"><span>Hovedkategori</span></legend>
3
Answers
I’ve encountered the same problem, try to use Mui Theme provider to create a override style theme. There are many small divs there that can get in your way, hide them or move them.
MUI themes
If you want resolve this problem you should add into your TextField component an css that modify MuiOutlinedInput-notchedOutline class.
With sx you can modify this class, and set the same font-size for fix your problem.
"&.MuiOutlinedInput-notchedOutline": { fontSize: "28px" }
You can use mui
Box
component and setfontSize
andfontWeight