Applying styles to p-dropdown element

UI Components for Angular
Post Reply
fmelo78
Posts: 3
Joined: 31 Aug 2021, 03:11

02 Dec 2021, 00:27

Hello, guys.

I'm trying to change the style of my p-dropdown element and I´m facing some problems.

Project Version: PrimeNG 12 / Primeflex 3

Looking around Internet, I found the following snippet, that works fine:
[style]="{'width':'100%', 'background-color':'greenyellow'}"

But I would like to keep all style rules concentrated in the CSS file, instead of using inline style, directly on the element. I tried the following codes, but none of them worked
<p-dropdown [class]="'dd-style'" [options]="cities" [(ngModel)]="selectedCity"></p-dropdown>
<p-dropdown class="dd-style" [options]="cities" [(ngModel)]="selectedCity"></p-dropdown>
<p-dropdown [styleClass]="'dd-style'" [options]="cities" [(ngModel)]="selectedCity"></p-dropdown>
<p-dropdown styleClass="dd-style" [options]="cities" [(ngModel)]="selectedCity"></p-dropdown>

My CSS class:
.dd-style {
width: 100% !important;
background-color: greenyellow;
}

Wraping up... Is that possible to keep the style rules for dropdown element concentrated in the CSS file?

Post Reply

Return to “PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 5 guests