Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[text field] Outlined input label is one pixel off #44341

Open
MonstraG opened this issue Nov 7, 2024 · 1 comment · May be fixed by #44342
Open

[text field] Outlined input label is one pixel off #44341

MonstraG opened this issue Nov 7, 2024 · 1 comment · May be fixed by #44342
Assignees
Labels
component: text field This is the name of the generic UI component, not the React module! design This is about UI or UX design, please involve a designer enhancement This is not a bug, nor a new feature package: material-ui Specific to @mui/material

Comments

@MonstraG
Copy link
Contributor

MonstraG commented Nov 7, 2024

Steps to reproduce

Here are 4 focused inputs:

image

  1. 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.

  1. 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

  1. Input 1, but with fieldset set to visibility: visible and label inside to opacity: 1, the white text is the aria label that also serves, thanks to it's padding, to create this "magin" in the border.

  2. 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)

transform: 'translate(14px, -9px) scale(0.75)',

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

@MonstraG MonstraG added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Nov 7, 2024
@MonstraG MonstraG linked a pull request Nov 7, 2024 that will close this issue
1 task
@zannager zannager added component: text field This is the name of the generic UI component, not the React module! component: input labels Nov 7, 2024
@siriwatknp siriwatknp added enhancement This is not a bug, nor a new feature package: material-ui Specific to @mui/material and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Nov 11, 2024
@oliviertassinari
Copy link
Member

This reminds me a bit of #36288

@oliviertassinari oliviertassinari changed the title [material-ui] Outlined input label is one pixel off [text field] Outlined input label is one pixel off Nov 12, 2024
@oliviertassinari oliviertassinari added design This is about UI or UX design, please involve a designer and removed component: input labels Nov 12, 2024
@mnajdova mnajdova assigned aarongarciah and unassigned mj12albert Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: text field This is the name of the generic UI component, not the React module! design This is about UI or UX design, please involve a designer enhancement This is not a bug, nor a new feature package: material-ui Specific to @mui/material
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants