354
Views
6
Comments
Solved
How to add in Dropdown text-overflow: ellipsis;

Hello all,

I have a case where I long texts in dropdown and the widget not have the width enough. I would like to implement text-overflow: ellipsis;

I already tried many solutions without success.

For example this one:

[data-dropdown] > select.dropdown-display {   

text-overflow: ellipsis;   

white-space: nowrap;   

overflow: hidden;

}


Someone have solution for this case?

Thanks in advance, Paulo Torres

2021-06-02 20-50-04
Márcio Carvalho
Solution

Can you share an OML? or a link to look at the inspect?

You must follow until the span of the dropdown. If you click with the inspect, you will see the path to change the span.

EDIT:

Try this, please, because you are using the native version. I am afraid

.dropdown-container > div.dropdown-display, .dropdown-container > select.dropdown-display{

    white-space: nowrap;

    text-overflow: ellipsis;

    overflow: hidden;

    padding-right: var(--space-l);

}

I would advise you to use the custom option of the dropdown

I hardcoded the values on the dom, and the options are a bit weird. Maybe it is just because I changed the value on the dom. Ps: this didn't happen with Custom.


2021-06-02 20-50-04
Márcio Carvalho

div.dropdown-display-content > span{

    white-space: nowrap;

    text-overflow: ellipsis;

    overflow: hidden;

    padding-right: var(--space-base)

}

For the items in the dropdown is the same


2023-08-28 07-00-10
Paulo Torres
Champion

Hello Márcio,

It seems not working for me, maybe I'm doing something wrong, no?

2021-06-02 20-50-04
Márcio Carvalho
Solution

Can you share an OML? or a link to look at the inspect?

You must follow until the span of the dropdown. If you click with the inspect, you will see the path to change the span.

EDIT:

Try this, please, because you are using the native version. I am afraid

.dropdown-container > div.dropdown-display, .dropdown-container > select.dropdown-display{

    white-space: nowrap;

    text-overflow: ellipsis;

    overflow: hidden;

    padding-right: var(--space-l);

}

I would advise you to use the custom option of the dropdown

I hardcoded the values on the dom, and the options are a bit weird. Maybe it is just because I changed the value on the dom. Ps: this didn't happen with Custom.


2023-08-28 07-00-10
Paulo Torres
Champion

This solution it was my workaround, there is no ellipsis but with padding at least the text is not in the arrow place.


2021-06-02 20-50-04
Márcio Carvalho

Sure, you must give padding with the width of at least the size of the chevron space

2023-08-28 07-00-10
Paulo Torres
Champion

Better than nothing :D But we just need padding because the rest not works.

Thanks @Márcio Carvalho 

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.