ColorPicker (Angular)

The ColorPicker control is a panel that allows users to pick colors. It is used as a drop-down by the InputColor control. You can customize the ColorPicker by changing the value of the showAlphaChannel, showColorString, and palette properties as in the sample below.

Learn about Input Controls | ColorPicker Overview Documentation | ColorPicker API Reference

This example uses Angular.

import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; import './styles.css'; // import { Component, enableProdMode, NgModule, Inject } from '@angular/core'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { FormsModule } from '@angular/forms'; import { BrowserModule } from '@angular/platform-browser'; import { WjInputModule } from '@grapecity/wijmo.angular2.input'; import { DataService, TPalette } from './app.data'; // @Component({ selector: 'app-component', templateUrl: 'src/app.component.html' }) export class AppComponent { palettes: TPalette[]; // constructor(@Inject(DataService) private dataService: DataService) { this.palettes = dataService.getPalettes(); } } // @NgModule({ imports: [WjInputModule, BrowserModule, FormsModule], declarations: [AppComponent], providers: [DataService], bootstrap: [AppComponent] }) export class AppModule { } // enableProdMode(); // Bootstrap application with hash style navigation and global services. platformBrowserDynamic().bootstrapModule(AppModule);
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>GrapeCity ColorPicker Overview</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- Polyfills --> <script src="node_modules/core-js/client/shim.min.js"></script> <script src="node_modules/zone.js/dist/zone.min.js"></script> <!-- SystemJS --> <script src="node_modules/systemjs/dist/system.js"></script> <script src="systemjs.config.js"></script> <script> // workaround to load 'rxjs/operators' from the rxjs bundle System.import('rxjs').then(function (m) { System.set(SystemJS.resolveSync('rxjs/operators'), System.newModule(m.operators)); System.import('./src/app.component'); }); </script> </head> <body> <app-component></app-component> </body> </html>
<div class="container-fluid"> <div id="output" [style.background]="theColorPicker.value"> Select a background for me! </div> <div class="form-check"> <label for="showAlphaChannel" class="form-check-label">showAlphaChannel:</label> <input id="showAlphaChannel" class="form-check-input" type="checkbox" [(ngModel)]="theColorPicker.showAlphaChannel"> </div> <div class="form-check"> <label for="showColorString" class="form-check-label">showColorString:</label> <input id="showColorString" class="form-check-input" type="checkbox" [(ngModel)]="theColorPicker.showColorString"> </div> <div class="form-check"> <label for="thePalette">palette: </label> <wj-combo-box #thePalette id="thePalette" [itemsSource]="palettes" [displayMemberPath]="'name'"> </wj-combo-box> </div> <wj-color-picker #theColorPicker [palette]="thePalette.selectedValue.colors" [showAlphaChannel]="true" [showColorString]="true"></wj-color-picker> </div>
import { Injectable } from '@angular/core'; // export type TPalette = { name: string; colors: string[] } // @Injectable() export class DataService { getPalettes() { return <TPalette[]>[ { name: 'default', colors: '#FFF,#000, #F00,#FFC000,#FFFF00,#92D050,#00B050,#00B0F0,#0070C0,#7030A0'.split(',') }, { name: 'standard', colors: '#88bde6,#fbb258,#90cd97,#f6aac9,#bfa554,#bc99c7,#eddd46,#f07e6e,#8c8c8c'.split(',') }, { name: 'cocoa', colors: '#466bb0,#c8b422,#14886e,#b54836,#6e5944,#8b3872,#73b22b,#b87320,#141414'.split(',') }, { name: 'coral', colors: '#84d0e0,#f48256,#95c78c,#efa5d6,#ba8452,#ab95c2,#ede9d0,#e96b7d,#888888'.split(',') }, { name: 'dark', colors: '#005fad,#f06400,#009330,#e400b1,#b65800,#6a279c,#d5a211,#dc0127,#000000'.split(',') }, { name: 'highcontrast', colors: '#ff82b0,#0dda2c,#0021ab,#bcf28c,#19c23b,#890d3a,#607efd,#1b7700,#000000'.split(',') }, { name: 'light', colors: '#ddca9a,#778deb,#778deb,#b5eae2,#7270be,#a6c7a7,#9e95c7,#95b0c7,#9b9b9b'.split(',') }, { name: 'midnight', colors: '#83aaca,#e37849,#14a46a,#e097da,#a26d54,#a584b7,#d89c54,#e86996,#2c343b'.split(',') }, { name: 'minimal', colors: '#92b8da,#e2d287,#accdb8,#eac4cb,#bbbb7a,#cab1ca,#cbd877,#dfb397,#c8c8c8'.split(',') }, { name: 'modern', colors: '#2d9fc7,#ec993c,#89c235,#e377a4,#a68931,#a672a6,#d0c041,#e35855,#68706a'.split(',') }, { name: 'organic', colors: '#9c88d9,#a3d767,#8ec3c0,#e9c3a9,#91ab36,#d4ccc0,#61bbd8,#e2d76f,#80715a'.split(',') }, { name: 'slate', colors: '#7493cd,#f99820,#71b486,#e4a491,#cb883b,#ae83a4,#bacc5c,#e5746a,#505d65'.split(',') }, { name: 'Standard', colors: '#fff,#000,#FFBE00,#FFFF00,#94D752,#00B652,#00B6EF,#0075C6,#002263,#73359C'.split(',') }, { name: 'Office', colors: '#fff,#000,#15487B,#EFEFE7,#4A82BD,#C6504A,#9CBA5A,#8465A5,#4AAEC6,#F79642'.split(',') }, { name: 'GrayScale', colors: '#fff,#000,#000000,#FFFFFF,#DEDEDE,#B4B4B4,#969696,#828282,#5A5A5A,#4B4B4B'.split(',') }, { name: 'Apex', colors: '#fff,#000,#6B656B,#CEC3D6,#CEBA63,#9CB284,#6BB2CE,#6386CE,#7B69CE,#A578BD'.split(',') }, { name: 'Aspect', colors: '#fff,#000,#332E33,#E7DFD6,#F77D00,#382733,#15597B,#4A8642,#63487B,#C69A5A'.split(',') }, { name: 'Civic', colors: '#fff,#000,#636984,#C6D3D6,#D6604A,#CEB600,#28AEAD,#8C7873,#8CB28C,#0E924A'.split(',') }, { name: 'Concourse', colors: '#fff,#000,#424442,#DEF7FF,#2BA2BD,#DE1C2B,#EF6515,#38609C,#42487B,#7B3D4A'.split(',') }, { name: 'Equity', colors: '#fff,#000,#6B6563,#EFE7DE,#D64815,#9C2B15,#A58E6B,#946052,#948684,#845D5A'.split(',') }, { name: 'Flow', colors: '#fff,#000,#00607B,#DEF7FF,#006DC6,#009EDE,#00D3DE,#15CF9C,#7BCB63,#A5C34A'.split(',') }, { name: 'Foundry', colors: '#fff,#000,#636952,#EFEBDE,#73A273,#B5CFB5,#ADCFD6,#C6BEAD,#CEC794,#EFB6B5'.split(',') }, { name: 'Median', colors: '#fff,#000,#735D52,#EFDFC6,#94B6D6,#DE8242,#A5AA84,#DEB25A,#7BA69C,#948E8C'.split(',') }, { name: 'Metro', colors: '#fff,#000,#4A596B,#D6EFFF,#7BD338,#EF157B,#FFBA00,#00AEDE,#738ACE,#15B29C'.split(',') }, { name: 'Module', colors: '#fff,#000,#5A607B,#D6D7D6,#F7AE00,#63B6CE,#E76D7B,#6BB66B,#EF8652,#C64842'.split(',') }, { name: 'Opulent', colors: '#fff,#000,#B53D9C,#F7E7EF,#BD3D6B,#AD65BD,#DE6D33,#FFB638,#CE6DA5,#FF8E38'.split(',') }, { name: 'Oriel', colors: '#fff,#000,#525D6B,#FFF39C,#FF8633,#739ADE,#B52B15,#F7CF2B,#ADBAD6,#737D84'.split(',') }, { name: 'Origin', colors: '#fff,#000,#424452,#DEEBEF,#737DA5,#9CBACE,#D6DB7B,#FFDB7B,#BD8673,#8C726B'.split(',') }, { name: 'Paper', colors: '#fff,#000,#424C22,#FFFBCE,#A5B694,#F7A642,#E7BE2B,#D692A5,#9C86C6,#849EC6'.split(',') }, { name: 'Solstice', colors: '#fff,#000,#4A2215,#E7DFCE,#3892A5,#FFBA00,#C62B2B,#84AA33,#944200,#42598C'.split(',') }, { name: 'Technic', colors: '#fff,#000,#383838,#D6D3D6,#6BA2B5,#CEAE00,#8C8AA5,#738663,#9C9273,#7B868C'.split(',') }, { name: 'Trek', colors: '#fff,#000,#4A3833,#FFEFCE,#F7A22B,#A5654A,#B58A84,#C69A6B,#A59673,#C6752B'.split(',') }, { name: 'Urban', colors: '#fff,#000,#424452,#DEDFDE,#52558C,#428284,#A54CA5,#C6652B,#8C5D38,#5A92B5'.split(',') }, { name: 'Verve', colors: '#fff,#000,#636563,#D6D3D6,#FF388C,#E7005A,#9C007B,#6B007B,#0059D6,#00359C'.split(',') } ]; } }
.wj-colorpicker { margin-bottom: 18px; } #output { float: right; font-size: 12px; border: 1px solid grey; padding: 12px; } label { width: 200px; text-align: right; margin-right: 3px; } body { margin-bottom: 24pt; }
(function (global) { System.config({ transpiler: 'ts', typescriptOptions: { tsconfig: true }, meta: { 'typescript': { "exports": "ts" }, '*.css': { loader: 'css' } }, paths: { // paths serve as alias 'npm:': 'node_modules/' }, // map tells the System loader where to look for things map: { 'core-js': 'npm:core-js/client/shim.min.js', 'zone': 'npm:zone.js/dist/zone.min.js', //'reflect-metadata': 'npm:reflect-metadata/Reflect.js', 'rxjs': 'npm:rxjs/bundles/rxjs.umd.min.js', //'rxjs': 'npm:rxjs', //'rxjs/operators': 'npm:rxjs/operators', '@angular/core': 'npm:@angular/core/bundles/core.umd.min.js', '@angular/common': 'npm:@angular/common/bundles/common.umd.min.js', '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.min.js', '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.min.js', '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.min.js', '@angular/http': 'npm:@angular/http/bundles/http.umd.min.js', '@angular/common/http': 'npm:@angular/common/bundles/common-http.umd.min.js', '@angular/router': 'npm:@angular/router/bundles/router.umd.min.js', '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.min.js', '@grapecity/wijmo': 'npm:@grapecity/wijmo/index.js', '@grapecity/wijmo.input': 'npm:@grapecity/wijmo.input/index.js', '@grapecity/wijmo.styles': 'npm:@grapecity/wijmo.styles', '@grapecity/wijmo.cultures': 'npm:@grapecity/wijmo.cultures', '@grapecity/wijmo.chart': 'npm:@grapecity/wijmo.chart/index.js', '@grapecity/wijmo.chart.analytics': 'npm:@grapecity/wijmo.chart.analytics/index.js', '@grapecity/wijmo.chart.animation': 'npm:@grapecity/wijmo.chart.animation/index.js', '@grapecity/wijmo.chart.annotation': 'npm:@grapecity/wijmo.chart.annotation/index.js', '@grapecity/wijmo.chart.finance': 'npm:@grapecity/wijmo.chart.finance/index.js', '@grapecity/wijmo.chart.finance.analytics': 'npm:@grapecity/wijmo.chart.finance.analytics/index.js', '@grapecity/wijmo.chart.hierarchical': 'npm:@grapecity/wijmo.chart.hierarchical/index.js', '@grapecity/wijmo.chart.interaction': 'npm:@grapecity/wijmo.chart.interaction/index.js', '@grapecity/wijmo.chart.radar': 'npm:@grapecity/wijmo.chart.radar/index.js', '@grapecity/wijmo.chart.render': 'npm:@grapecity/wijmo.chart.render/index.js', '@grapecity/wijmo.chart.webgl': 'npm:@grapecity/wijmo.chart.webgl/index.js', '@grapecity/wijmo.chart.map': 'npm:@grapecity/wijmo.chart.map/index.js', '@grapecity/wijmo.gauge': 'npm:@grapecity/wijmo.gauge/index.js', '@grapecity/wijmo.grid': 'npm:@grapecity/wijmo.grid/index.js', '@grapecity/wijmo.grid.detail': 'npm:@grapecity/wijmo.grid.detail/index.js', '@grapecity/wijmo.grid.filter': 'npm:@grapecity/wijmo.grid.filter/index.js', '@grapecity/wijmo.grid.search': 'npm:@grapecity/wijmo.grid.search/index.js', '@grapecity/wijmo.grid.grouppanel': 'npm:@grapecity/wijmo.grid.grouppanel/index.js', '@grapecity/wijmo.grid.multirow': 'npm:@grapecity/wijmo.grid.multirow/index.js', '@grapecity/wijmo.grid.transposed': 'npm:@grapecity/wijmo.grid.transposed/index.js', '@grapecity/wijmo.grid.transposedmultirow': 'npm:@grapecity/wijmo.grid.transposedmultirow/index.js', '@grapecity/wijmo.grid.pdf': 'npm:@grapecity/wijmo.grid.pdf/index.js', '@grapecity/wijmo.grid.sheet': 'npm:@grapecity/wijmo.grid.sheet/index.js', '@grapecity/wijmo.grid.xlsx': 'npm:@grapecity/wijmo.grid.xlsx/index.js', '@grapecity/wijmo.grid.selector': 'npm:@grapecity/wijmo.grid.selector/index.js', '@grapecity/wijmo.grid.cellmaker': 'npm:@grapecity/wijmo.grid.cellmaker/index.js', '@grapecity/wijmo.nav': 'npm:@grapecity/wijmo.nav/index.js', '@grapecity/wijmo.odata': 'npm:@grapecity/wijmo.odata/index.js', '@grapecity/wijmo.olap': 'npm:@grapecity/wijmo.olap/index.js', '@grapecity/wijmo.rest': 'npm:@grapecity/wijmo.rest/index.js', '@grapecity/wijmo.pdf': 'npm:@grapecity/wijmo.pdf/index.js', '@grapecity/wijmo.pdf.security': 'npm:@grapecity/wijmo.pdf.security/index.js', '@grapecity/wijmo.viewer': 'npm:@grapecity/wijmo.viewer/index.js', '@grapecity/wijmo.xlsx': 'npm:@grapecity/wijmo.xlsx/index.js', '@grapecity/wijmo.undo': 'npm:@grapecity/wijmo.undo/index.js', '@grapecity/wijmo.interop.grid': 'npm:@grapecity/wijmo.interop.grid/index.js', '@grapecity/wijmo.touch': 'npm:@grapecity/wijmo.touch/index.js', '@grapecity/wijmo.cloud': 'npm:@grapecity/wijmo.cloud/index.js', '@grapecity/wijmo.barcode': 'npm:@grapecity/wijmo.barcode/index.js', '@grapecity/wijmo.barcode.common': 'npm:@grapecity/wijmo.barcode.common/index.js', '@grapecity/wijmo.barcode.composite': 'npm:@grapecity/wijmo.barcode.composite/index.js', '@grapecity/wijmo.barcode.specialized': 'npm:@grapecity/wijmo.barcode.specialized/index.js', "@grapecity/wijmo.angular2.chart.analytics": "npm:@grapecity/wijmo.angular2.chart.analytics/index.js", "@grapecity/wijmo.angular2.chart.animation": "npm:@grapecity/wijmo.angular2.chart.animation/index.js", "@grapecity/wijmo.angular2.chart.annotation": "npm:@grapecity/wijmo.angular2.chart.annotation/index.js", "@grapecity/wijmo.angular2.chart.finance.analytics": "npm:@grapecity/wijmo.angular2.chart.finance.analytics/index.js", "@grapecity/wijmo.angular2.chart.finance": "npm:@grapecity/wijmo.angular2.chart.finance/index.js", "@grapecity/wijmo.angular2.chart.hierarchical": "npm:@grapecity/wijmo.angular2.chart.hierarchical/index.js", "@grapecity/wijmo.angular2.chart.interaction": "npm:@grapecity/wijmo.angular2.chart.interaction/index.js", "@grapecity/wijmo.angular2.chart.radar": "npm:@grapecity/wijmo.angular2.chart.radar/index.js", '@grapecity/wijmo.angular2.chart.map': 'npm:@grapecity/wijmo.angular2.chart.map/index.js', "@grapecity/wijmo.angular2.chart": "npm:@grapecity/wijmo.angular2.chart/index.js", "@grapecity/wijmo.angular2.core": "npm:@grapecity/wijmo.angular2.core/index.js", "@grapecity/wijmo.angular2.gauge": "npm:@grapecity/wijmo.angular2.gauge/index.js", "@grapecity/wijmo.angular2.grid.detail": "npm:@grapecity/wijmo.angular2.grid.detail/index.js", "@grapecity/wijmo.angular2.grid.filter": "npm:@grapecity/wijmo.angular2.grid.filter/index.js", "@grapecity/wijmo.angular2.grid.grouppanel": "npm:@grapecity/wijmo.angular2.grid.grouppanel/index.js", "@grapecity/wijmo.angular2.grid.search": "npm:@grapecity/wijmo.angular2.grid.search/index.js", "@grapecity/wijmo.angular2.grid.multirow": "npm:@grapecity/wijmo.angular2.grid.multirow/index.js", "@grapecity/wijmo.angular2.grid.sheet": "npm:@grapecity/wijmo.angular2.grid.sheet/index.js", '@grapecity/wijmo.angular2.grid.transposed': 'npm:@grapecity/wijmo.angular2.grid.transposed/index.js', '@grapecity/wijmo.angular2.grid.transposedmultirow': 'npm:@grapecity/wijmo.angular2.grid.transposedmultirow/index.js', "@grapecity/wijmo.angular2.grid": "npm:@grapecity/wijmo.angular2.grid/index.js", "@grapecity/wijmo.angular2.input": "npm:@grapecity/wijmo.angular2.input/index.js", "@grapecity/wijmo.angular2.olap": "npm:@grapecity/wijmo.angular2.olap/index.js", "@grapecity/wijmo.angular2.viewer": "npm:@grapecity/wijmo.angular2.viewer/index.js", "@grapecity/wijmo.angular2.nav": "npm:@grapecity/wijmo.angular2.nav/index.js", "@grapecity/wijmo.angular2.directivebase": "npm:@grapecity/wijmo.angular2.directivebase/index.js", '@grapecity/wijmo.angular2.barcode.common': 'npm:@grapecity/wijmo.angular2.barcode.common/index.js', '@grapecity/wijmo.angular2.barcode.composite': 'npm:@grapecity/wijmo.angular2.barcode.composite/index.js', '@grapecity/wijmo.angular2.barcode.specialized': 'npm:@grapecity/wijmo.angular2.barcode.specialized/index.js', 'bootstrap.css': 'npm:bootstrap/dist/css/bootstrap.min.css', 'jszip': 'npm:jszip/dist/jszip.min.js', 'typescript': 'npm:typescript/lib/typescript.js', //'typescript': 'https://unpkg.com/typescript@3.2.2', 'ts': 'npm:plugin-typescript/lib/plugin.js', 'css': 'npm:systemjs-plugin-css/css.js' }, // packages tells the System loader how to load when no filename and/or no extension packages: { src: { defaultExtension: 'ts' }, rxjs: { defaultExtension: 'js' }, // 'rxjs': {main: 'index.js', defaultExtension: 'js' }, // 'rxjs/ajax': {main: 'index.js', defaultExtension: 'js' }, //'rxjs/operators': {main: 'index.js', defaultExtension: 'js' }, // 'rxjs/testing': {main: 'index.js', defaultExtension: 'js' }, // 'rxjs/webSocket': {main: 'index.js', defaultExtension: 'js' }, "node_modules": { defaultExtension: 'js' }, wijmo: { defaultExtension: 'js', } } }); })(this);