1

I have been working with PrimeNG as the UI library to an Angular TypeScript application I have been developing and I have been having trouble customizing the font size styling and the dropdown trigger icon styling of the PrimeNG dropdown that I have put together. It seems the styling documentation for PrimeNG is rather vague on how to customize it.

No matter how I try to adjust it, the font size does not change within the dropdown. I am not sure if I should use the inline style in html, a property in TypeScript, or override the PrimeNG CSS styling to accomplish this. This also goes for the Dropdown Trigger icon.

Here is my HTML, TypeScript, and CSS.

<p-dropdown [options]="heights" [style]="{'font-size':'12px'}" [(ngModel)]="height" (ngModelChange)="adjustHeight()">
</p-dropdown>
heights: SelectItem[] = [
    {label: 'Table Size: Small', value: 'Small'},
    {label: 'Table Size: Large', value: 'Large'}
];
.p-dropdown {
    font-size: 12px !important;
}

.p-dropdown-trigger {
    font-size 12px !important
}

Update: Using what was suggested below and a simple adjustment to the style class referred to in PrimeNG I was able to change the font size of the text in a p-dropdown with:

:host ::ng-deep .p-dropdown-label {
    font-size: 12px !important;
}

1 Answer 1

1

try this :-

:host ::ng-deep .p-dropdown {
    font-size: 12px !important;
}

:host ::ng-deep .p-dropdown-trigger {
    font-size 12px !important
}
Sign up to request clarification or add additional context in comments.

5 Comments

I was able to change the font size of the dropdown text using :host ::ng-deep .p-dropdown-label { .... } , but for some reason the dropdown trigger icon sizing won't change even with this method.
@NicFalcione can you provide a stackblitz?
You should replace .p-dropdown-trigger with .p-dropdown-trigger-icon.
didn't work....

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.