Mode and value in Angular Color picker component
27 Apr 20243 minutes to read
Rendering palette at initial load
By default, the Picker
area will be rendered at initial load. To render the Palette area while opening the ColorPicker pop-up, and specify the mode
property as Palette
.
In the following sample, it will render the Palette
at initial load.
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { FormsModule } from '@angular/forms'
import { ColorPickerModule } from '@syncfusion/ej2-angular-inputs'
import { enableRipple } from '@syncfusion/ej2-base'
import { Component } from '@angular/core';
@Component({
imports: [
FormsModule,ColorPickerModule
],
standalone: true,
selector: 'app-root',
template: `<div class="e-section-control">
<h4>Select Color</h4>
<ejs-input ejs-colorpicker type="color" id="element" mode="Palette" /></div>`
})
export class AppComponent { }
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
Color value
The value
property can be used to specify the color value to the ColorPicker. It supports either three
or six
digit hex codes. To include opacity
, set the color value as four
or eight
digit hex code.
In the following sample, the color value sets as four
digit hex code, the last digit represents the opacity
value.
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { FormsModule } from '@angular/forms'
import { ColorPickerModule } from '@syncfusion/ej2-angular-inputs'
import { enableRipple } from '@syncfusion/ej2-base'
import { Component } from '@angular/core';
@Component({
imports: [
FormsModule, ColorPickerModule
],
standalone: true,
selector: 'app-root',
template: `<div class="e-section-control">
<h4>Choose Color</h4>
<!-- To set color value. -->
<ejs-input ejs-colorpicker type="color" id="element" value="035a" /></div>`
})
export class AppComponent { }
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
The
value
property supports hex code with or without#
prefix.