Styling Select.Value
See original GitHub issueI’m not sure how important it is for Select.Value to not be styled. It’s preventing me from using Select.Trigger as a flex
container and adding flex: 1
to Select.Value to get the select to stretch to fill the container.
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:5
Top Results From Across the Web
How to style the option of an html "select" element?
This is a html css code used to style option and select tag. Selected option : background and bold After closing , it...
Read more >How To Create Custom Select Menus - W3Schools
Surround the select box within a "custom-select" DIV element. Remember to set the width: --> <div class="custom-select" style="width:200px;"> <select>
Read more >Custom Select Styles with Pure CSS | Modern CSS Solutions
Modern CSS gives us a range of properties to achieve custom select styles that have a near-identical initial appearance.
Read more >Styling the Standard Select with CSS and HTML
Learn how to style custom with CSS and HTML. Web developers follow along with code examples in this programming tutorial.
Read more >HTML select style Attribute - Dofactory
A style attribute on a <select> tag assigns a unique style to the dropdown. Its value is CSS that defines the appearance of...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
HI @benoitgrelard.
The first method is the better option for me. I had no idea you were allowed to do that though and I can see how both methods can be overused to avoid the style filtering on the
Select.Value
.Now I’ve seen it’s possible/allowed to add a parent to the
Select.Value
. From what I can assume, any extra styles you want on it can be done that way. Like in @avin-kavish’s case, If I addflex: 1
, the extra span does fill the container, and theSelect.Value
does as well.So just using another parent may work for simple cases and you probably won’t have to change anything with the current behaviour, but add a section in the docs talking about adding an extra parent as a means to add styles to the
Select.Value
that the user is sure won’t change its original position. I’m obviously not sure and haven’t run any tests, so If what I’m saying isn’t stable or advised or straight-up crap, forgive me🙏.Thanks again and have a nice rest of your day. I appreciate it 🙌
Hey @iammola,
Yeah the truncating/ellipsis is definitely one I’ve been thinking about. I am reluctant to add “easy” styling of
Value
though but perhaps as people will expect it to “just work” in all cases. But maybe I am worrying too much… not sure.In the meantime, you could do this as an escape hatch:
Or, you could even use CSS to target that first span:
I am aware that with that second method you can still break it by adding padding-left for example, because you’re now adding styles directly to the value, rather than a parent, but at least you have to get out of your way to break it.
What do you think?