htmlangularinputangular-formsngmodel

How to Change the default color of <input type="color">?


I'm using Angular and want to change the default color of an <input type="color"> element. Currently, it shows black (#000) as the default, but I want to set it to a different color. How can I achieve this?

Also, I'm using Angular v18. I've tried setting the value attribute, but it doesn't work.

My code snippet:

<input type="color" name="color" value="#ff0000" ngModel />

Solution

  • <input type="color" name="color" [(ngModel)]="selectedColor" value="#ff0000" />
    
    export class AppComponent {
      selectedColor: string = '#ff0000';  // default color red
    }