Fit contents in flex layout
See original GitHub issueI have a very simple setup - a display: flex
header with a logo on the left and a react-select
on the right.
But, as you can see, react-select
doesn’t stretch to fit the value. I’ve tried a lot of options, but nothing seems to work. Does anyone have a solution?
I have asked this question on SO as well, with little traction…
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Shrink to fit content in flexbox, or flex-basis - Stack Overflow
I want columns One and Two to shrink/grow to fit rather than being fixed. ... it looks like the column isn't growing to...
Read more >flex-basis - CSS: Cascading Style Sheets - MDN Web Docs
The flex-basis CSS property sets the initial main size of a flex item. It sets the size of the content box unless otherwise...
Read more >Shrink flex item to fit content - HTML & CSS - SitePoint Forums
The <a> element stretches as long as the page width. How can we shrink it so it fits the content? ... Use the...
Read more >How to Make Flex Items Take the Content Width - W3docs
In this snippet, learn how to make flex items take the content width instead of the width of the parent container. Use either...
Read more >Making width and flexible items play nice together | CSS-Tricks
The short answer: flex-shrink and flex-basis are probably what you're ... Let's say you want to align an image and some text next...
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 FreeTop 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
Top GitHub Comments
Thanks @ebonow , I ended up using a version of your solution. I used
position: relative
onsingleValue
.@artooras Hello again,
The styling I think you are looking for is based on the SingleValue. Since the default styling is set to
position: absolute
, it will not flex without some styling overrides.I responded to a thread recently discussing how to create an inline React-Select (with a working sandbox example). While you would likely want to keep the Indicators and borders, it should fit as a proof of concept of flexing the width of the Select to fit the value.
This is likely the bit of styling you are looking for to apply to the SingleValue component