Is there a way to have a lightning:select
auto sizing to the biggest of its option
?
<lightning:select>
<option value="1">short name</option>
<option value="2">longest name of options</option>
</lightning:select>
Is there a way to have a lightning:select
auto sizing to the biggest of its option
?
<lightning:select>
<option value="1">short name</option>
<option value="2">longest name of options</option>
</lightning:select>
Best Answer
The problem is that the
lightning:select
lightning component includes a select input inside a container.Here's the code automatically added:
The container with the class
slds-select_container
is displayed as a block which takes all the width available. So, you have to change this.First, add a custom class to your input like this:
Now, in your component style, you have to add: