Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

primeNG p-dropdown stretch 100%

Tags:

css

primeng

How to set the primeNG dropdown width to stretch 100% inside its container?

It seems to have fixed element.style and the .ui-dropdown{ width: 100% } override does not work.

like image 840
McLac Avatar asked Dec 28 '16 02:12

McLac


People also ask

How do I set default value in Primeng dropdown?

Update in PrimgNg Where select and id are supposedly the default label and value. Just specify name optionLabel and optionValue. So the label key's value will be used for display and value key's value will be used in ngModel.

What is P dropdown?

p-dropdown-label: It is a styling element to display the label of the selected option. p-dropdown-trigger: It is a styling icon element.


2 Answers

In my case I used autoWidth = false and set style attrribute like below

<p-dropdown [options]="educationLevels" [(ngModel)]="selectedEducationLevel" 
name="educationlevel" autoWidth="false" [style]="{'width':'100%'}"></p-dropdown>
like image 83
Ziggler Avatar answered Oct 19 '22 18:10

Ziggler


I found to use the Responsive approach and apply .ui-fluid style with Grid CSS at container while p-dropdown should have the [autoWidth]="false" attribute.

Example:

<div class="ui-grid ui-grid-responsive ui-fluid">
    <div class="ui-grid-row">
        <div class="ui-grid-col-12">
            <p-dropdown [autoWidth]="false"></p-dropdown>
        </div>
    </div>
</div>
like image 35
McLac Avatar answered Oct 19 '22 18:10

McLac