-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
[TextField] Long labels break layout #12255
Comments
@csantos1113 We can try to solve the issue by inverting the positioning strategy. We should be able to use |
@csantos1113 @oliviertassinari |
@kybarg It should, but we have the opportunity to make the implementation more flexible without extra cost. Well, in the case of the outlined text field, it's a dead-end, the text won't stay within the parent background boundaries. |
@oliviertassinari Just wondering what the resolution to the issue was, and how I should handle multiline labels (specifically as long labels condense on mobile devices). Thanks! |
The resolution is: we don't support it, we don't want to support it. I would encourage you to increase the width of your input, or to reduce the width of your label or to use the helper text under the input. |
Any workaround on this issue ? My labels are dynamic with diferent lenghts. At least, is there a way to disable wrapping and set text overflow to ellipsis ? |
I would recommend that you implement a hard ellipses logic: if .length > x then cut and add |
Sorry this wont work with respinsive design and various label texts. Ill give it a try if there wont be another solution. If i only could determine if label overflows, i could use helper text sa you recommended instead. |
Yes, you could also use layout measurements. |
I found a workaround to trim label with ellipsis
and in my component
result looks like this: |
Thanks for sharing. |
Long lables break the layout and it won't be fixed: mui/material-ui#12255, so for long labels we'll use helper text instead
Would you all be willing to reconsider the decision on this issue? Irrespective of what the Goog says, the world is full of long questions in forms. The idea of short labels only holds good for limited cases of "username / password / address / credit card" and the like. I can give dozens of examples of long questions in forms, that needs be there, and not all of it can be turned into helper text. Eg surveys / questionnaire are terrible on small screens. |
Re-opening since we should have a documented, simple workaround for automatically scaling the textfield so that it fits the label. |
@zehawki #12255 (comment) this is outdated, it's how v4 behaves. We changed the solution in v5 with #25012. What version are you using? What's the visual output that you see? What solution do you envision? |
@oliviertassinari I saw that as well (I looked thru all the issue threads around this issue), and I beg to differ with that solution. Its not good UX. I saw a similar comment from another person: #26248 (comment) Starting here https://next.material-ui.com/components/text-fields/. This shows me v5.0.0-beta.1. From there to https://codesandbox.io/s/461qq?file=/demo.js&resolutionWidth=320&resolutionHeight=675, and I changed one of the labels, which gives me: As you can see, this is very troublesome. I'm truly sorry to bring up this issue again, after its gone through so much churn thru the years :-(
I'm on v4.11.
|
Oh here is a possibly elegant solution - one that is no longer available in v5 due to the (...) change. When the label is looooooong, one could use a Multiline version of the textlabel. This together with a Edit: Nope doesnt work out of the box. |
Another good workaround for me was to position label using transform-origin bottom property instead of top. Using this approach label will be aligned on bottom also when wraps. Doesn't work with multiline edits :/ or you can try to use calc in shrinked transform |
@oliviertassinari : In reference to these two comments. |
For anyone trying to resolve this is v4..
|
Regarding the next step on this issue, AFAIK, this is not solvable within the Material Design methodology. However, we are working on second design system, code name Joy. I think that it would be great to evaluate using a similar layout to Bootstrap, with an isolated label and input. Meaning no floating label. This has been a controversial topic, e.g. https://www.smashingmagazine.com/2021/02/material-design-text-fields/. cc @siriwatknp |
It is definitely solvable. The problem is integrating the solution with backwards compatibility. |
@eps1lon Ah, nice. Could you expand on the solution with the floating label of Material Design? :) Maybe a community member could then take it on in a PR. |
Hi @ErikParso, do you happen to have a sandbox for this? I am trying to do what you described above and it is not working for me. Thanks. |
Can you please provide a sandbox |
This issue has been open since 2018 and is still not resolved. Has anyone managed to resolve this issue locally? |
I changed it in theme and set label positioning from bottom (changed transformOrigin to bottom left) so text will move upside when it wraps.
Change label position as you want. Result looks like this |
@ErikParso thank you for the reply, unfortunately, this method does not seem to work with MUI v5.x |
You have to transform label slightly higher and to the right (16px) in your case. |
As @oliviertassinari mentioned up in this thread, I've also come to believe that its not solvable in MUI because this is how its designed in Google's material design for text fields (aka chic-but-useless). Google itself has been conflicted in form field design. This format was intended for short fields (username / email and the like), and is not meant for long fields. As one can see there are dozens of examples on that page with short fields. All the methods proposed in this thread either lead to loss of info or legibility and/or cognitive overload - which is basically bad UX, and form fields being really important cannot afford to have poor UX. One is better served by using a classical format for text fields. We ourselves have adopted this practice and its relieved our customers and end users. Real examples: Google material design: Classical: For non-english characters and perhaps even non-sophisticated audiences, we find it better to use classical format for forms, even for short fields. Google material design: Classical: And all our text fields are also classical: |
I've solved this issue by overriding the MUI MuiFormLabel-root class in my global CSS file. |
As pointed out by @zehawki, I think long label should not be used with floating label. I think a suggestion on the docs and example of tacking the long label is the solution to this issue. Anyway, I am closing this because we aim to have a fresh look for Material UI in the near future. |
This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue. Note @csantos1113 How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey. |
I'm reopening because I believe we will need to support the outline input, even in this new design direction. e.g. https://www.twilio.com/login I don't see this going away, |
The textfield layout is not responsive when there are long labels.
Expected Behavior
According to Material Design, long labels should be correctly positioned within the available input space:
Current Behavior
Steps to Reproduce
https://codesandbox.io/s/6xjr79vx3w
Context
Your Environment
The text was updated successfully, but these errors were encountered: