PrimeNG: CSS background for p-inputNumber

Viewed 1663

I am using PrimeNG and find a way to set the background-color of a p-inputNumber control.

It is working fine with pInputText.

<!-- OK -->
<input pInputText type="text" style="background: red;"/>

<!-- Not OK -->
<p-inputNumber [showButtons]="true" style="background: red;"></p-inputNumber>
2 Answers

Thanks for the hint! I found the inline attribute too.

 <p-inputNumber [showButtons]="true" [inputStyle]="{background: 'red'}"></p-inputNumber>

p-inputNumber is a component rather than a simple input element and it style in different way base of the documentation page you can add a class for the internal input element by using the property inputStyleClass

add the css class in global style file

style.css

input.bg-red{
 background:red;
 color:#fff;
}

template

 <p-inputNumber inputStyleClass="bg-red" [(ngModel)]="value1"></p-inputNumber>

stackblitz demo

Related