[text field] Outlined input label is one pixel off
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 99.1k
- Forks
- 32.5k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 106
Description
Steps to reproduce
Here are 4 focused inputs:
- Outlined input as seen on https://mui.com/material-ui/react-text-field/
This input's styles have
transform: translate(14px, -9px) scale(0.75);
by default.
- Same input, but I've set
transform: translate(15px, -9px) scale(0.75);
Just comparing input 1 and input 2, to my eye, the "margin" where there is no border looks more even in the version 2 than in the version 1. But, we can check that if we see where the "margin" comes from
-
Input 1, but with
fieldsetset tovisibility: visibleand label inside toopacity: 1, the white text is the aria label that also serves, thanks to it's padding, to create this "magin" in the border. -
Input 2, but with fieldset visible.
It is quite clear in inputs 3 and 4 that the label is misaligned to the fieldset. The version in 4th is still not quite 100% there, but it's much less than a pixel off, so I'm not sure what can be done about it.
In order to fix the mismatch either the fieldset invisible version must be moved, or the visible version must be moved.
If the transtion is to be changed, here it is:
(but don't forget about the non-focused versions)
Another option is to change the NotchedOutline here:
from padding: 0 8px to padding: 0 7px, because 1px of horizontal size is provided by the border anyway. I think this is actually the most correct change.
Search keywords: Outlined input label misaligned
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.