Autosize ng-select width to longest option width
See original GitHub issueIs your feature request related to a problem? Please describe.
Default <select>
behavior is to size itself to the width of the longest option it contains. This allows for the select to stay fixed width throughout the process of selecting options and prevents “content jumping” in inline forms.
Describe the solution you’d like Mimic regular select behavior. Currently, you can only set width by css, but you don’t know the width of largest possible option during runtime and there’s apparently no way to calculate that, as options are not in DOM, until clicked.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:10
- Comments:10 (2 by maintainers)
Top Results From Across the Web
make ng-select width adjust to selected items / available ...
I'd like it to be sized such that the width is at least the maximum width the component would have if any one...
Read more >How to Expand Select Box to its Default Width on Focus ...
Answer: Use the CSS :focus pseudo-class. By default the size of the <select> element is depend on the size of the largest <option>...
Read more >ng-select fixed width
ng-select -container width. Default <select> behavior is to size itself to the width of the longest option it contains. This allows for the...
Read more >ngSelect Customizations: Draggable Panel
Today I'm writing about how I made the ng-select dropdown resize by ... panel width, panel height, dragging boolean, and X/Y coordinates.
Read more >Material2 Select Width Issues
font-size: 8pt;. float: right;. } .alt { .mat-form-field {. width: auto !important;. } .mat-select-value {. max-width: 100%;. width: auto;. }.
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
I don’t think this is good practice, usually your control is based on parents width or static width you define. Width based on longest option will result in miss-aligned UI and problems with overflowing content. I think this feature will add unnecessary complexity and extra calculations and the benefit won’t outweigh the cost.
here is simple working scss solution