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

Add prefix and suffix for text fields #1892

Closed
ribrdb opened this issue Jan 8, 2018 · 4 comments · Fixed by #5796
Closed

Add prefix and suffix for text fields #1892

ribrdb opened this issue Jan 8, 2018 · 4 comments · Fixed by #5796

Comments

@ribrdb
Copy link

ribrdb commented Jan 8, 2018

Feature Request

Please add support for prefixes and suffixes as shown here:
https://material.io/guidelines/components/text-fields.html#text-fields-input-types

This seems like it's probably pretty similar to the leading and trailing icons you already support.

@lynnmercier lynnmercier changed the title Support prefix and suffix for text fields Investigate prefix and suffix for text fields Jan 23, 2018
@mikehans9
Copy link

mikehans9 commented Dec 13, 2018

@lynnmercier @acdvorak jesus......almost one year and the most basic feature for textfields still not done? a simple prefix/suffix? crazy.

@jamesmfriedman
Copy link
Contributor

This just came up for RMWC. Thinking about adding it in myself, but it isn't actually easy to support. This is a relatively complex issue due to the fact that the size of the prefix or suffix is unknown so it can't just be added like the icons are with padding. The solution then would be something like making the container display flex, but having the input only be a small piece of it, and having the other elements outside of it, then deferring focus to the input if anything else is clicked.

@ChainsDD
Copy link

ChainsDD commented May 9, 2019

I've created a mostly working solution. I still need to support leading and trailing icons, and convert it to a material component. Once that's done I'll post it here to get some more feedback.

Basically I'm positioning a span on top of the input, and adjusting the padding of the input to account for it. It's working pretty well, I'll try and throw something up on codepen to demonstrate it.

edit) Here's what I've got so far. Like I said, still need to support leading/trailing icons, and turn it into a material component, but it works as far as I can tell. Definitely open to feedback, I'm fairly new to this kind of development.

last edit) Icon support added to the pen, just added CSS classes to the affixes to adjust their padding if there's an icon.

@patrickrodee
Copy link
Contributor

@asyncLiz

@asyncLiz asyncLiz self-assigned this Nov 20, 2019
@asyncLiz asyncLiz changed the title Investigate prefix and suffix for text fields Add prefix and suffix for text fields Dec 12, 2019
copybara-service bot pushed a commit that referenced this issue Apr 8, 2020
Fixes #1892

PiperOrigin-RevId: 305502022
copybara-service bot pushed a commit that referenced this issue Apr 9, 2020
Fixes #1892

PiperOrigin-RevId: 305502022
aforemny pushed a commit to aforemny/material-components-web that referenced this issue Mar 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants