rob-balfre / svelte-select

Svelte Select. A select component for Svelte
https://svelte-select-examples.vercel.app
Other
1.25k stars 175 forks source link

wrap item text when long #601

Closed kewp closed 1 year ago

kewp commented 1 year ago

I'm just putting this here so anyone can find it in the future (took me a long time to get working!)

This is what you need to do if you want the text in your drop-downs to wrap properly:

<Select 
     --item-line-height = "auto"
     --item-height = "auto">

    <div class='myitem' slot="item" let:item let:index>
        {item.label}
    </div>

</Select>

<style>
:global(.myitem) {
    white-space: normal !important;
}
</style>
kewp commented 1 year ago

btw to make the drop-down width larger than the input box width see here https://github.com/rob-balfre/svelte-select/issues/599