md-color-picker spec card
Identity · when to use / when NOT · decision cues · behavioural contract · do/don't · anti-patterns · full API. Paste into your agent when you're implementing with this component.
Pick an arbitrary colour. A saturation/value plate with a hue slider, optional alpha slider, numeric fields in hex / RGB / HSL, and an optional row of preset swatches. Renders inline (default) or as a popover behind your own trigger.
<!-- index.html — register the AWC UI elements once -->
<script type="module">
import '@awc-ui/core/define';
</script>
<md-color-picker
value="#6750A4"
presets="#6750A4,#B3261E,#146C2E,#1B5E9F"
aria-label="Accent colour"
></md-color-picker>import { MdColorPicker } from '@awc-ui/react';
export function Demo() {
return (
<>
<MdColorPicker
value="#6750A4"
presets="#6750A4,#B3261E,#146C2E,#1B5E9F"
aria-label="Accent colour"
></MdColorPicker>
</>
);
}// app.module.ts — register the AWC UI elements once
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
import { AwcUiModule } from '@awc-ui/angular';
@NgModule({
imports: [AwcUiModule],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
export class AppModule {}
<!-- app.component.html -->
<md-color-picker
value="#6750A4"
presets="#6750A4,#B3261E,#146C2E,#1B5E9F"
aria-label="Accent colour"
></md-color-picker><script setup>
import '@awc-ui/core/define';
</script>
<template>
<md-color-picker
value="#6750A4"
presets="#6750A4,#B3261E,#146C2E,#1B5E9F"
aria-label="Accent colour"
></md-color-picker>
</template><script>
import '@awc-ui/core/define';
</script>
<md-color-picker
value="#6750A4"
presets="#6750A4,#B3261E,#146C2E,#1B5E9F"
aria-label="Accent colour"
></md-color-picker>
Already installed? See the
Installation guide for one-time package setup
(core + tokens, fonts). Each tab below shows two patterns for using
md-color-picker in your project: Option A registers every AWC UI
component at once (simplest), Option B imports only this component for
tree-shake-friendly bundles.
<!-- ─── Option A: global registration (all components) ─── -->
<script type="module">
import '@awc-ui/core/define';
</script>
<!-- ─── Option B: single import (tree-shake only md-color-picker) ─── -->
<script type="module">
import '@awc-ui/core/components/md-color-picker';
</script>
<md-color-picker></md-color-picker>// ─── Option A: typed React wrapper (registers all components) ───
// Importing from '@awc-ui/react' calls defineCustomElements() as a
// side effect, so every md-* element becomes available in the browser.
import { MdColorPicker } from '@awc-ui/react';
export function Example() {
return <MdColorPicker></MdColorPicker>;
}
// ─── Option B: single import (tree-shake to only md-color-picker) ───
// Skip the wrapper and use the raw custom element. Smallest bundle,
// but you lose typed props/events on JSX.
import '@awc-ui/core/components/md-color-picker';
export function ExampleTreeShaken() {
return <md-color-picker></md-color-picker>;
}// ─── Option A: schema module (any md-* element accepted) ───
// Pair with `defineCustomElements(window)` in main.ts.
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { AwcUiModule } from '@awc-ui/angular';
@Component({
standalone: true,
imports: [AwcUiModule],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
template: `<md-color-picker></md-color-picker>`,
})
export class ExampleComponent {}
// ─── Option B: typed directive (tree-shake friendly) ───
// Pair with `import '@awc-ui/core/components/md-color-picker'` in main.ts.
import { Component } from '@angular/core';
import { MdColorPicker } from '@awc-ui/angular';
@Component({
standalone: true,
imports: [MdColorPicker],
template: `<md-color-picker></md-color-picker>`,
})
export class ExampleTreeShakenComponent {}<!-- ─── Option A: typed Vue wrapper (registers all components) ─── -->
<script setup lang="ts">
import { MdColorPicker } from '@awc-ui/vue';
</script>
<template>
<MdColorPicker></MdColorPicker>
</template>
<!-- ─── Option B: single import (tree-shake to only md-color-picker) ─── -->
<script setup lang="ts">
import '@awc-ui/core/components/md-color-picker';
</script>
<template>
<md-color-picker></md-color-picker>
</template><!-- ─── Option A: global registration (done once in main entry) ─── -->
<!-- main.ts: -->
<!-- import { defineCustomElements } from '@awc-ui/svelte'; -->
<!-- defineCustomElements(window); -->
<md-color-picker></md-color-picker>
<!-- ─── Option B: single import (tree-shake to only md-color-picker) ─── -->
<script lang="ts">
import '@awc-ui/core/components/md-color-picker';
</script>
<md-color-picker></md-color-picker>| Situation | Use instead |
|---|---|
| A small fixed palette (e.g. 8 label colours) | md-chip or md-segmented-button swatches, or presets only |
| Choosing a semantic status | md-select with named options |
| A value that must submit with a form | Mirror it into a hidden field yourself |
| A greyscale / intensity amount | md-slider |
| Only a hex string typed by hand | md-text-field with a pattern |
| Need | Setting |
|---|---|
| Always-visible panel | variant="inline" |
| A trigger of your own that opens a dialog | variant="popover" + a slotted trigger |
| Transparency | An alpha-carrying format, plus the alpha track |
| A fixed palette to pick from | presets |
| Hide the numeric fields | show-inputs="false" — think first |
| Hide just the hex field | show-hex="false" |
| Compact panel | density="-1…-4" |
| Variant | Behaviour |
|---|---|
inline | Default. The panel is always visible — embed it in a settings panel or sidebar |
popover | Opens the panel in a floating dialog behind a trigger you slot |
<!-- index.html <head> — the icon font the components draw from -->
<link rel="stylesheet"
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200&display=swap">
<!-- index.html — register the AWC UI elements once -->
<script type="module">
import '@awc-ui/core/define';
</script>
<md-color-picker variant="popover" value="#B3261E" aria-label="Brand colour">
<md-button slot="trigger" variant="outlined" icon="palette">Brand colour</md-button>
</md-color-picker>
<md-color-picker variant="popover" value="#146C2E" aria-label="Accent colour">
<md-icon-button slot="trigger" icon="format_color_fill" aria-label="Accent colour"></md-icon-button>
</md-color-picker>
<md-color-picker variant="popover" value="#1B5E9F" aria-label="Label colour">
<md-chip slot="trigger" appearance="assist" icon="label">Label colour</md-chip>
</md-color-picker>// Icons need the Material Symbols stylesheet in index.html — see Installation.
import { MdButton, MdChip, MdColorPicker, MdIconButton } from '@awc-ui/react';
export function Demo() {
return (
<>
<MdColorPicker variant="popover" value="#B3261E" aria-label="Brand colour">
<MdButton slot="trigger" variant="outlined" icon="palette">Brand colour</MdButton>
</MdColorPicker>
<MdColorPicker variant="popover" value="#146C2E" aria-label="Accent colour">
<MdIconButton slot="trigger" icon="format_color_fill" aria-label="Accent colour"></MdIconButton>
</MdColorPicker>
<MdColorPicker variant="popover" value="#1B5E9F" aria-label="Label colour">
<MdChip slot="trigger" appearance="assist" icon="label">Label colour</MdChip>
</MdColorPicker>
</>
);
}// Icons need the Material Symbols stylesheet in index.html — see Installation.
// app.module.ts — register the AWC UI elements once
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
import { AwcUiModule } from '@awc-ui/angular';
@NgModule({
imports: [AwcUiModule],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
export class AppModule {}
<!-- app.component.html -->
<md-color-picker variant="popover" value="#B3261E" aria-label="Brand colour">
<md-button slot="trigger" variant="outlined" icon="palette">Brand colour</md-button>
</md-color-picker>
<md-color-picker variant="popover" value="#146C2E" aria-label="Accent colour">
<md-icon-button slot="trigger" icon="format_color_fill" aria-label="Accent colour"></md-icon-button>
</md-color-picker>
<md-color-picker variant="popover" value="#1B5E9F" aria-label="Label colour">
<md-chip slot="trigger" appearance="assist" icon="label">Label colour</md-chip>
</md-color-picker><script setup>
// Icons need the Material Symbols stylesheet in index.html — see Installation.
import '@awc-ui/core/define';
</script>
<template>
<md-color-picker variant="popover" value="#B3261E" aria-label="Brand colour">
<md-button slot="trigger" variant="outlined" icon="palette">Brand colour</md-button>
</md-color-picker>
<md-color-picker variant="popover" value="#146C2E" aria-label="Accent colour">
<md-icon-button slot="trigger" icon="format_color_fill" aria-label="Accent colour"></md-icon-button>
</md-color-picker>
<md-color-picker variant="popover" value="#1B5E9F" aria-label="Label colour">
<md-chip slot="trigger" appearance="assist" icon="label">Label colour</md-chip>
</md-color-picker>
</template><script>
// Icons need the Material Symbols stylesheet in index.html — see Installation.
import '@awc-ui/core/define';
</script>
<md-color-picker variant="popover" value="#B3261E" aria-label="Brand colour">
<md-button slot="trigger" variant="outlined" icon="palette">Brand colour</md-button>
</md-color-picker>
<md-color-picker variant="popover" value="#146C2E" aria-label="Accent colour">
<md-icon-button slot="trigger" icon="format_color_fill" aria-label="Accent colour"></md-icon-button>
</md-color-picker>
<md-color-picker variant="popover" value="#1B5E9F" aria-label="Label colour">
<md-chip slot="trigger" appearance="assist" icon="label">Label colour</md-chip>
</md-color-picker>For variant="popover", open reflects the panel state and show() /
close() control it programmatically. mdOpenChange reports every transition.
value is a string in the current format, and it is two-way bindable
(mutable + reflected).
format | Emitted shape | With alpha |
|---|---|---|
hex | Default. #6750A4 | 8-digit hex, #6750A4CC |
rgb | rgb(103, 80, 164) | rgba(103, 80, 164, 0.8) |
hsl | hsl(258, 34%, 48%) | hsla(258, 34%, 48%, 0.8) |
On input, value accepts any 3/4/6/8-digit hex, rgb() or rgba() — but what
comes out always follows format.
<!-- index.html — register the AWC UI elements once -->
<script type="module">
import '@awc-ui/core/define';
</script>
<div style="display: flex; gap: 24px; flex-wrap: wrap;">
<md-color-picker format="hex" value="#6750A4" show-inputs="false" aria-label="Hex output"></md-color-picker>
<md-color-picker format="rgb" alpha value="rgba(103,80,164,0.8)" aria-label="RGBA output"></md-color-picker>
</div>import { MdColorPicker } from '@awc-ui/react';
export function Demo() {
return (
<>
<div style={{ display: 'flex', gap: '24px', flexWrap: 'wrap' }}>
<MdColorPicker format="hex" value="#6750A4" showInputs="false" aria-label="Hex output"></MdColorPicker>
<MdColorPicker format="rgb" alpha value="rgba(103,80,164,0.8)" aria-label="RGBA output"></MdColorPicker>
</div>
</>
);
}// app.module.ts — register the AWC UI elements once
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
import { AwcUiModule } from '@awc-ui/angular';
@NgModule({
imports: [AwcUiModule],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
export class AppModule {}
<!-- app.component.html -->
<div style="display: flex; gap: 24px; flex-wrap: wrap;">
<md-color-picker format="hex" value="#6750A4" show-inputs="false" aria-label="Hex output"></md-color-picker>
<md-color-picker format="rgb" alpha value="rgba(103,80,164,0.8)" aria-label="RGBA output"></md-color-picker>
</div><script setup>
import '@awc-ui/core/define';
</script>
<template>
<div style="display: flex; gap: 24px; flex-wrap: wrap;">
<md-color-picker format="hex" value="#6750A4" show-inputs="false" aria-label="Hex output"></md-color-picker>
<md-color-picker format="rgb" alpha value="rgba(103,80,164,0.8)" aria-label="RGBA output"></md-color-picker>
</div>
</template><script>
import '@awc-ui/core/define';
</script>
<div style="display: flex; gap: 24px; flex-wrap: wrap;">
<md-color-picker format="hex" value="#6750A4" show-inputs="false" aria-label="Hex output"></md-color-picker>
<md-color-picker format="rgb" alpha value="rgba(103,80,164,0.8)" aria-label="RGBA output"></md-color-picker>
</div>alpha only has meaning in formats that carry it — with format="hex" expect
the 8-digit form.
presets accepts either form — the comma-separated attribute in markup, or
an array assigned as a property from JS. Whitespace and empty entries are
ignored either way, so it behaves like every other list-valued prop in the
library.
Presets render as a role="listbox" of focusable swatches below the sliders,
and clicking one commits immediately (it fires mdInput and mdChange).
<!-- index.html — register the AWC UI elements once -->
<script type="module">
import '@awc-ui/core/define';
</script>
<!-- Attribute: comma-separated -->
<md-color-picker
value="#146C2E"
presets="#6750A4,#B3261E,#146C2E,#1B5E9F,#000000,#FFFFFF"
aria-label="Brand colour"
></md-color-picker>
<!-- Property: an array -->
<md-color-picker id="brand" value="#146C2E" aria-label="Brand colour"></md-color-picker>
<script type="module">
const el = document.getElementById('brand');
el.presets = ['#6750A4', '#B3261E', '#146C2E', '#1B5E9F', '#000000', '#FFFFFF'];
</script>import { MdColorPicker } from '@awc-ui/react';
const presets = ['#6750A4', '#B3261E', '#146C2E', '#1B5E9F', '#000000', '#FFFFFF'];
export function Demo() {
return (
<>
<!-- Attribute: comma-separated -->
<MdColorPicker
value="#146C2E"
presets="#6750A4,#B3261E,#146C2E,#1B5E9F,#000000,#FFFFFF"
aria-label="Brand colour"
></MdColorPicker>
<!-- Property: an array -->
<MdColorPicker id="brand"
presets={presets} value="#146C2E" aria-label="Brand colour"></MdColorPicker>
</>
);
}// app.module.ts — register the AWC UI elements once
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
import { AwcUiModule } from '@awc-ui/angular';
@NgModule({
imports: [AwcUiModule],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
export class AppModule {}
// app.component.ts — the bound values live on the class
import { Component } from '@angular/core';
@Component({
selector: 'app-demo',
templateUrl: './app.component.html',
})
export class DemoComponent {
presets = ['#6750A4', '#B3261E', '#146C2E', '#1B5E9F', '#000000', '#FFFFFF'];
}
<!-- app.component.html -->
<!-- Attribute: comma-separated -->
<md-color-picker
value="#146C2E"
presets="#6750A4,#B3261E,#146C2E,#1B5E9F,#000000,#FFFFFF"
aria-label="Brand colour"
></md-color-picker>
<!-- Property: an array -->
<md-color-picker id="brand"
[presets]="presets" value="#146C2E" aria-label="Brand colour"></md-color-picker><script setup>
import '@awc-ui/core/define';
const presets = ['#6750A4', '#B3261E', '#146C2E', '#1B5E9F', '#000000', '#FFFFFF'];
</script>
<template>
<!-- Attribute: comma-separated -->
<md-color-picker
value="#146C2E"
presets="#6750A4,#B3261E,#146C2E,#1B5E9F,#000000,#FFFFFF"
aria-label="Brand colour"
></md-color-picker>
<!-- Property: an array -->
<md-color-picker id="brand"
:presets="presets" value="#146C2E" aria-label="Brand colour"></md-color-picker>
</template><script>
import '@awc-ui/core/define';
const presets = ['#6750A4', '#B3261E', '#146C2E', '#1B5E9F', '#000000', '#FFFFFF'];
</script>
<!-- Attribute: comma-separated -->
<md-color-picker
value="#146C2E"
presets="#6750A4,#B3261E,#146C2E,#1B5E9F,#000000,#FFFFFF"
aria-label="Brand colour"
></md-color-picker>
<!-- Property: an array -->
<md-color-picker id="brand"
{presets} value="#146C2E" aria-label="Brand colour"></md-color-picker>| Prop | Default | Effect |
|---|---|---|
show-hex | true | The hex field below the sliders |
show-inputs | true | The RGB / HSL numeric channel fields |
<!-- index.html — register the AWC UI elements once -->
<script type="module">
import '@awc-ui/core/define';
</script>
<div style="display: flex; gap: 24px; flex-wrap: wrap;">
<md-color-picker show-inputs="false" aria-label="Plate only"></md-color-picker>
<md-color-picker show-hex="false" aria-label="No hex field"></md-color-picker>
<md-color-picker disabled value="#79747E" aria-label="Disabled picker"></md-color-picker>
</div>import { MdColorPicker } from '@awc-ui/react';
export function Demo() {
return (
<>
<div style={{ display: 'flex', gap: '24px', flexWrap: 'wrap' }}>
<MdColorPicker showInputs="false" aria-label="Plate only"></MdColorPicker>
<MdColorPicker showHex="false" aria-label="No hex field"></MdColorPicker>
<MdColorPicker disabled value="#79747E" aria-label="Disabled picker"></MdColorPicker>
</div>
</>
);
}// app.module.ts — register the AWC UI elements once
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
import { AwcUiModule } from '@awc-ui/angular';
@NgModule({
imports: [AwcUiModule],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
export class AppModule {}
<!-- app.component.html -->
<div style="display: flex; gap: 24px; flex-wrap: wrap;">
<md-color-picker show-inputs="false" aria-label="Plate only"></md-color-picker>
<md-color-picker show-hex="false" aria-label="No hex field"></md-color-picker>
<md-color-picker disabled value="#79747E" aria-label="Disabled picker"></md-color-picker>
</div><script setup>
import '@awc-ui/core/define';
</script>
<template>
<div style="display: flex; gap: 24px; flex-wrap: wrap;">
<md-color-picker show-inputs="false" aria-label="Plate only"></md-color-picker>
<md-color-picker show-hex="false" aria-label="No hex field"></md-color-picker>
<md-color-picker disabled value="#79747E" aria-label="Disabled picker"></md-color-picker>
</div>
</template><script>
import '@awc-ui/core/define';
</script>
<div style="display: flex; gap: 24px; flex-wrap: wrap;">
<md-color-picker show-inputs="false" aria-label="Plate only"></md-color-picker>
<md-color-picker show-hex="false" aria-label="No hex field"></md-color-picker>
<md-color-picker disabled value="#79747E" aria-label="Disabled picker"></md-color-picker>
</div>| Event | Cancelable | Detail | Fires |
|---|---|---|---|
mdInput | no | { value: string } | Continuously while dragging the plate, hue or alpha, and on every keystroke in a field |
mdChange | no | { value: string } | On commit — pointer release, field blur, Enter, or a preset click |
mdOpenChange | no | { open: boolean } | The popover opened or closed |
There is no ElementInternals form participation here — unlike
md-button or
md-text-field, this component contributes nothing
to FormData. Mirror the value into a hidden input on mdChange:
<!-- index.html — register the AWC UI elements once -->
<script type="module">
import '@awc-ui/core/define';
</script>
<form id="theme">
<md-color-picker id="picker" value="#6750A4" aria-label="Accent colour"></md-color-picker>
<input type="hidden" name="accent" id="accent" value="#6750A4">
<md-button variant="filled" type="submit">Save theme</md-button>
</form>
<script type="module">
const picker = document.getElementById('picker');
const hidden = document.getElementById('accent');
picker.addEventListener('mdChange', (e) => { hidden.value = e.detail.value; });
document.getElementById('theme').addEventListener('submit', (e) => {
e.preventDefault();
console.log(Object.fromEntries(new FormData(e.target))); // { accent: '#6750A4' }
});
</script>import { MdButton, MdColorPicker } from '@awc-ui/react';
import { useState } from 'react';
export function ThemeForm() {
const [accent, setAccent] = useState('#6750A4');
function onSubmit(e: React.FormEvent<HTMLFormElement>) {
e.preventDefault();
console.log(Object.fromEntries(new FormData(e.currentTarget)));
}
return (
<form onSubmit={onSubmit}>
<MdColorPicker
value={accent}
aria-label="Accent colour"
onMdChange={(e) => setAccent(e.detail.value)}
/>
{/* the picker is not form-associated — this input carries the value */}
<input type="hidden" name="accent" value={accent} />
<MdButton variant="filled" type="submit">Save theme</MdButton>
</form>
);
}import { Component } from '@angular/core';
@Component({
selector: 'app-theme-form',
template: `
<form (submit)="onSubmit($event)">
<md-color-picker
[attr.value]="accent"
aria-label="Accent colour"
(mdChange)="accent = $event.detail.value"
></md-color-picker>
<input type="hidden" name="accent" [value]="accent" />
<md-button variant="filled" type="submit">Save theme</md-button>
</form>
`,
})
export class ThemeFormComponent {
accent = '#6750A4';
onSubmit(e: Event) {
e.preventDefault();
console.log(Object.fromEntries(new FormData(e.target as HTMLFormElement)));
}
}<script setup lang="ts">
import { ref } from 'vue';
const accent = ref('#6750A4');
function onSubmit(e: Event) {
e.preventDefault();
console.log(Object.fromEntries(new FormData(e.target as HTMLFormElement)));
}
</script>
<template>
<form @submit="onSubmit">
<md-color-picker
:value="accent"
aria-label="Accent colour"
@mdChange="accent = $event.detail.value"
/>
<input type="hidden" name="accent" :value="accent" />
<md-button variant="filled" type="submit">Save theme</md-button>
</form>
</template><script lang="ts">
let accent = '#6750A4';
function onSubmit(e: Event) {
e.preventDefault();
console.log(Object.fromEntries(new FormData(e.target as HTMLFormElement)));
}
</script>
<form on:submit={onSubmit}>
<md-color-picker
value={accent}
aria-label="Accent colour"
on:mdChange={(e) => (accent = e.detail.value)}
/>
<input type="hidden" name="accent" value={accent} />
<md-button variant="filled" type="submit">Save theme</md-button>
</form>The plate, the hue slider and the alpha slider are three separate drag
surfaces. Each needs a real pointer drag — pointerdown → pointermove →
pointerup on that surface. A synthetic click will not move any of them, and
a drag on the plate says nothing about hue or alpha, so cover all three.
Setting value directly is the fast path for everything that is not
specifically about dragging.
| Property | Attribute | Type | Default | Reflects |
|---|---|---|---|---|
variant | variant | ColorPickerVariant | 'inline' | Yes |
value | value | string | '#6750A4' | Yes |
format | format | ColorFormat | 'hex' | Yes |
alpha | alpha | boolean | false | Yes |
showHex | show-hex | boolean | true | — |
showInputs | show-inputs | boolean | true | — |
disabled | disabled | boolean | false | Yes |
presets | presets | string | string[] | '' | — |
ariaLabelProp | aria-label | string | 'Color picker' | — |
open | open | boolean | false | Yes |
dismissOnOutsideClick | dismiss-on-outside-click | boolean | false | — |
density | density | 0 | -1 | -2 | -3 | -4 | 0 | Yes |
| Method | Parameters |
|---|---|
show() | none |
close() | none |
| Slot | Description |
|---|---|
trigger | — |
Override on the host element for per-instance theming:
| Property | Description |
|---|---|
--md-color-picker-width | Panel inline-size |
--md-color-picker-plate-height | Saturation/value plate height |
--md-color-picker-radius | Outer container radius |
--md-color-picker-surface-color | Panel background colour |
--md-color-picker-on-surface | Panel text colour |
--md-color-picker-outline-color | Field outlines |
--md-color-picker-thumb-size | Slider thumb size |
--md-color-picker-thumb-border | Thumb ring colour |
--md-color-picker-preset-size | Preset swatch size |
--md-color-picker-popover-elevation | Popover shadow/elevation |
--md-color-picker-outline-strong | — |
Style internal elements through shadow DOM with ::part():
| Part | Description |
|---|---|
plate | — |
thumb | — |
hue | — |
alpha | — |
field-hex | — |
label | — |
field-a | — |
inputs | — |
field-r | — |
field-g | — |
field-b | — |
field-h | — |
field-s | — |
field-l | — |
presets | — |
preset | — |
panel | — |
sliders | — |
preview | — |
popover | — |
aria-label — the default is the English string "Color picker".show-inputs="false" removes it, so think hard before setting it.role="application" with arrow-key handling; the hue and alpha
tracks are role="slider" with aria-valuenow. All three are in the tab
order unless disabled.role="listbox"; give them meaningful
surrounding text where you can.role="dialog" labelled by aria-label. The component
puts aria-haspopup="dialog" and a live aria-expanded on your slotted
trigger — but its accessible name is yours to write, since the element is
yours (an icon-only trigger needs an aria-label).| Key | Action |
|---|---|
Tab | Plate → hue track → alpha track → numeric fields → presets |
← → ↑ ↓ | Move the plate thumb, or step the focused hue / alpha track |
Home / End | Jump a track to its ends |
Enter / Space | Pick a focused preset; open the popover from its trigger |
Escape | Close the popover, returning focus to the trigger |
<!-- index.html — register the AWC UI elements once -->
<script type="module">
import '@awc-ui/core/define';
</script>
<md-color-picker variant="inline" value="#6750A4" aria-label="Brand colour"></md-color-picker>import { MdColorPicker } from '@awc-ui/react';
export function Demo() {
return (
<>
<MdColorPicker variant="inline" value="#6750A4" aria-label="Brand colour"></MdColorPicker>
</>
);
}// app.module.ts — register the AWC UI elements once
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
import { AwcUiModule } from '@awc-ui/angular';
@NgModule({
imports: [AwcUiModule],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
export class AppModule {}
<!-- app.component.html -->
<md-color-picker variant="inline" value="#6750A4" aria-label="Brand colour"></md-color-picker><script setup>
import '@awc-ui/core/define';
</script>
<template>
<md-color-picker variant="inline" value="#6750A4" aria-label="Brand colour"></md-color-picker>
</template><script>
import '@awc-ui/core/define';
</script>
<md-color-picker variant="inline" value="#6750A4" aria-label="Brand colour"></md-color-picker>RTL — the panel layout mirrors under dir="rtl". The hue and alpha
gradients keep their colour order; that ordering is not directional. See
RTL.
<!-- index.html — register the AWC UI elements once -->
<script type="module">
import '@awc-ui/core/define';
</script>
<div style="display:flex;gap:24px;flex-wrap:wrap;">
<div dir="ltr"><md-color-picker variant="inline" value="#6750A4" aria-label="Brand colour" style="inline-size: 260px;"></md-color-picker></div>
<div dir="rtl"><md-color-picker variant="inline" value="#6750A4" aria-label="لون العلامة" style="inline-size: 260px;"></md-color-picker></div>
</div>import { MdColorPicker } from '@awc-ui/react';
export function Demo() {
return (
<>
<div style={{ display: 'flex', gap: '24px', flexWrap: 'wrap' }}>
<div dir="ltr"><MdColorPicker variant="inline" value="#6750A4" aria-label="Brand colour" style={{ inlineSize: '260px' }}></MdColorPicker></div>
<div dir="rtl"><MdColorPicker variant="inline" value="#6750A4" aria-label="لون العلامة" style={{ inlineSize: '260px' }}></MdColorPicker></div>
</div>
</>
);
}// app.module.ts — register the AWC UI elements once
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
import { AwcUiModule } from '@awc-ui/angular';
@NgModule({
imports: [AwcUiModule],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
export class AppModule {}
<!-- app.component.html -->
<div style="display:flex;gap:24px;flex-wrap:wrap;">
<div dir="ltr"><md-color-picker variant="inline" value="#6750A4" aria-label="Brand colour" style="inline-size: 260px;"></md-color-picker></div>
<div dir="rtl"><md-color-picker variant="inline" value="#6750A4" aria-label="لون العلامة" style="inline-size: 260px;"></md-color-picker></div>
</div><script setup>
import '@awc-ui/core/define';
</script>
<template>
<div style="display:flex;gap:24px;flex-wrap:wrap;">
<div dir="ltr"><md-color-picker variant="inline" value="#6750A4" aria-label="Brand colour" style="inline-size: 260px;"></md-color-picker></div>
<div dir="rtl"><md-color-picker variant="inline" value="#6750A4" aria-label="لون العلامة" style="inline-size: 260px;"></md-color-picker></div>
</div>
</template><script>
import '@awc-ui/core/define';
</script>
<div style="display:flex;gap:24px;flex-wrap:wrap;">
<div dir="ltr"><md-color-picker variant="inline" value="#6750A4" aria-label="Brand colour" style="inline-size: 260px;"></md-color-picker></div>
<div dir="rtl"><md-color-picker variant="inline" value="#6750A4" aria-label="لون العلامة" style="inline-size: 260px;"></md-color-picker></div>
</div>Density — density="-1…-4" compacts the panel and forwards the rung to the
embedded text fields. See Density.
<!-- index.html — register the AWC UI elements once -->
<script type="module">
import '@awc-ui/core/define';
</script>
<div style="display:flex;gap:20px;flex-wrap:wrap;align-items:flex-start;">
<md-color-picker density="0" value="#6750A4" aria-label="Density 0"></md-color-picker>
<md-color-picker density="-1" value="#6750A4" aria-label="Density -1"></md-color-picker>
<md-color-picker density="-2" value="#6750A4" aria-label="Density -2"></md-color-picker>
<md-color-picker density="-3" value="#6750A4" aria-label="Density -3"></md-color-picker>
<md-color-picker density="-4" value="#6750A4" aria-label="Density -4"></md-color-picker>
</div>import { MdColorPicker } from '@awc-ui/react';
export function Demo() {
return (
<>
<div style={{ display: 'flex', gap: '20px', flexWrap: 'wrap', alignItems: 'flex-start' }}>
<MdColorPicker density="0" value="#6750A4" aria-label="Density 0"></MdColorPicker>
<MdColorPicker density="-1" value="#6750A4" aria-label="Density -1"></MdColorPicker>
<MdColorPicker density="-2" value="#6750A4" aria-label="Density -2"></MdColorPicker>
<MdColorPicker density="-3" value="#6750A4" aria-label="Density -3"></MdColorPicker>
<MdColorPicker density="-4" value="#6750A4" aria-label="Density -4"></MdColorPicker>
</div>
</>
);
}// app.module.ts — register the AWC UI elements once
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
import { AwcUiModule } from '@awc-ui/angular';
@NgModule({
imports: [AwcUiModule],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
export class AppModule {}
<!-- app.component.html -->
<div style="display:flex;gap:20px;flex-wrap:wrap;align-items:flex-start;">
<md-color-picker density="0" value="#6750A4" aria-label="Density 0"></md-color-picker>
<md-color-picker density="-1" value="#6750A4" aria-label="Density -1"></md-color-picker>
<md-color-picker density="-2" value="#6750A4" aria-label="Density -2"></md-color-picker>
<md-color-picker density="-3" value="#6750A4" aria-label="Density -3"></md-color-picker>
<md-color-picker density="-4" value="#6750A4" aria-label="Density -4"></md-color-picker>
</div><script setup>
import '@awc-ui/core/define';
</script>
<template>
<div style="display:flex;gap:20px;flex-wrap:wrap;align-items:flex-start;">
<md-color-picker density="0" value="#6750A4" aria-label="Density 0"></md-color-picker>
<md-color-picker density="-1" value="#6750A4" aria-label="Density -1"></md-color-picker>
<md-color-picker density="-2" value="#6750A4" aria-label="Density -2"></md-color-picker>
<md-color-picker density="-3" value="#6750A4" aria-label="Density -3"></md-color-picker>
<md-color-picker density="-4" value="#6750A4" aria-label="Density -4"></md-color-picker>
</div>
</template><script>
import '@awc-ui/core/define';
</script>
<div style="display:flex;gap:20px;flex-wrap:wrap;align-items:flex-start;">
<md-color-picker density="0" value="#6750A4" aria-label="Density 0"></md-color-picker>
<md-color-picker density="-1" value="#6750A4" aria-label="Density -1"></md-color-picker>
<md-color-picker density="-2" value="#6750A4" aria-label="Density -2"></md-color-picker>
<md-color-picker density="-3" value="#6750A4" aria-label="Density -3"></md-color-picker>
<md-color-picker density="-4" value="#6750A4" aria-label="Density -4"></md-color-picker>
</div>i18n — translate aria-label and any surrounding labels. Channel
abbreviations (R/G/B, H/S/L) are conventional and normally stay untranslated.
| Custom property | Purpose |
|---|---|
--md-color-picker-width | Panel inline size |
--md-color-picker-plate-height | Saturation/value plate height |
--md-color-picker-radius | Outer container radius |
--md-color-picker-surface-color / --md-color-picker-on-surface | Panel background and text |
--md-color-picker-outline-color / --md-color-picker-outline-strong | Field outlines and stronger borders |
--md-color-picker-thumb-size / --md-color-picker-thumb-border | Plate/slider thumb |
--md-color-picker-preset-size | Preset swatch size |
--md-color-picker-popover-elevation | Popover shadow |
<!-- index.html — register the AWC UI elements once -->
<script type="module">
import '@awc-ui/core/define';
</script>
<div style="display:flex;gap:20px;flex-wrap:wrap;align-items:flex-start;">
<md-color-picker variant="inline" value="#6750A4" aria-label="Default" style="inline-size: 240px;"></md-color-picker>
<md-color-picker variant="inline" value="#00897B" aria-label="Squared, tall plate" style="inline-size: 240px; --md-color-picker-radius: 4px; --md-color-picker-plate-height: 200px; --md-color-picker-thumb-size: 22px;"></md-color-picker>
<md-color-picker variant="inline" value="#E65100" aria-label="Branded surface" style="inline-size: 240px; --md-color-picker-surface-color: var(--md-sys-color-secondary-container); --md-color-picker-on-surface: var(--md-sys-color-on-secondary-container); --md-color-picker-outline-color: var(--md-sys-color-primary);"></md-color-picker>
</div>import { MdColorPicker } from '@awc-ui/react';
export function Demo() {
return (
<>
<div style={{ display: 'flex', gap: '20px', flexWrap: 'wrap', alignItems: 'flex-start' }}>
<MdColorPicker variant="inline" value="#6750A4" aria-label="Default" style={{ inlineSize: '240px' }}></MdColorPicker>
<MdColorPicker variant="inline" value="#00897B" aria-label="Squared, tall plate" style={{ inlineSize: '240px', '--md-color-picker-radius': '4px', '--md-color-picker-plate-height': '200px', '--md-color-picker-thumb-size': '22px' }}></MdColorPicker>
<MdColorPicker variant="inline" value="#E65100" aria-label="Branded surface" style={{ inlineSize: '240px', '--md-color-picker-surface-color': 'var(--md-sys-color-secondary-container)', '--md-color-picker-on-surface': 'var(--md-sys-color-on-secondary-container)', '--md-color-picker-outline-color': 'var(--md-sys-color-primary)' }}></MdColorPicker>
</div>
</>
);
}// app.module.ts — register the AWC UI elements once
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
import { AwcUiModule } from '@awc-ui/angular';
@NgModule({
imports: [AwcUiModule],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
export class AppModule {}
<!-- app.component.html -->
<div style="display:flex;gap:20px;flex-wrap:wrap;align-items:flex-start;">
<md-color-picker variant="inline" value="#6750A4" aria-label="Default" style="inline-size: 240px;"></md-color-picker>
<md-color-picker variant="inline" value="#00897B" aria-label="Squared, tall plate" style="inline-size: 240px; --md-color-picker-radius: 4px; --md-color-picker-plate-height: 200px; --md-color-picker-thumb-size: 22px;"></md-color-picker>
<md-color-picker variant="inline" value="#E65100" aria-label="Branded surface" style="inline-size: 240px; --md-color-picker-surface-color: var(--md-sys-color-secondary-container); --md-color-picker-on-surface: var(--md-sys-color-on-secondary-container); --md-color-picker-outline-color: var(--md-sys-color-primary);"></md-color-picker>
</div><script setup>
import '@awc-ui/core/define';
</script>
<template>
<div style="display:flex;gap:20px;flex-wrap:wrap;align-items:flex-start;">
<md-color-picker variant="inline" value="#6750A4" aria-label="Default" style="inline-size: 240px;"></md-color-picker>
<md-color-picker variant="inline" value="#00897B" aria-label="Squared, tall plate" style="inline-size: 240px; --md-color-picker-radius: 4px; --md-color-picker-plate-height: 200px; --md-color-picker-thumb-size: 22px;"></md-color-picker>
<md-color-picker variant="inline" value="#E65100" aria-label="Branded surface" style="inline-size: 240px; --md-color-picker-surface-color: var(--md-sys-color-secondary-container); --md-color-picker-on-surface: var(--md-sys-color-on-secondary-container); --md-color-picker-outline-color: var(--md-sys-color-primary);"></md-color-picker>
</div>
</template><script>
import '@awc-ui/core/define';
</script>
<div style="display:flex;gap:20px;flex-wrap:wrap;align-items:flex-start;">
<md-color-picker variant="inline" value="#6750A4" aria-label="Default" style="inline-size: 240px;"></md-color-picker>
<md-color-picker variant="inline" value="#00897B" aria-label="Squared, tall plate" style="inline-size: 240px; --md-color-picker-radius: 4px; --md-color-picker-plate-height: 200px; --md-color-picker-thumb-size: 22px;"></md-color-picker>
<md-color-picker variant="inline" value="#E65100" aria-label="Branded surface" style="inline-size: 240px; --md-color-picker-surface-color: var(--md-sys-color-secondary-container); --md-color-picker-on-surface: var(--md-sys-color-on-secondary-container); --md-color-picker-outline-color: var(--md-sys-color-primary);"></md-color-picker>
</div>Every default resolves through an md-sys-color role, so a picker that sets no
custom properties follows the theme on its own:
<!-- index.html — register the AWC UI elements once -->
<script type="module">
import '@awc-ui/core/define';
</script>
<md-color-picker variant="inline" value="#6750A4" aria-label="Untouched defaults" style="inline-size: 280px;"></md-color-picker>import { MdColorPicker } from '@awc-ui/react';
export function Demo() {
return (
<>
<MdColorPicker variant="inline" value="#6750A4" aria-label="Untouched defaults" style={{ inlineSize: '280px' }}></MdColorPicker>
</>
);
}// app.module.ts — register the AWC UI elements once
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
import { AwcUiModule } from '@awc-ui/angular';
@NgModule({
imports: [AwcUiModule],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
export class AppModule {}
<!-- app.component.html -->
<md-color-picker variant="inline" value="#6750A4" aria-label="Untouched defaults" style="inline-size: 280px;"></md-color-picker><script setup>
import '@awc-ui/core/define';
</script>
<template>
<md-color-picker variant="inline" value="#6750A4" aria-label="Untouched defaults" style="inline-size: 280px;"></md-color-picker>
</template><script>
import '@awc-ui/core/define';
</script>
<md-color-picker variant="inline" value="#6750A4" aria-label="Untouched defaults" style="inline-size: 280px;"></md-color-picker>| Part | Element |
|---|---|
panel | The whole panel surface |
plate / thumb | Saturation–value plate and its thumb |
hue / alpha / sliders | The two tracks and their row |
preview | The current-colour swatch |
inputs / label | Numeric field row and its labels |
field-hex | The hex field |
field-r / -g / -b | RGB fields |
field-h / -s / -l | HSL fields |
field-a | Alpha field |
presets / preset | Preset listbox and each swatch |
popover | The floating panel surface (variant="popover") |
<!-- index.html — register the AWC UI elements once -->
<script type="module">
import '@awc-ui/core/define';
</script>
<style>
.parts-cp::part(plate) { border-radius: 12px; }
.parts-cp::part(thumb) { border-width: 3px; }
.parts-cp::part(preview) { border-radius: 4px; outline: 2px solid var(--md-sys-color-primary); }
.parts-cp::part(label) { text-transform: uppercase; letter-spacing: .08em; font-size: 10px; }
</style>
<md-color-picker class="parts-cp" variant="inline" value="#6750A4" aria-label="Styled parts" style="inline-size: 280px;"></md-color-picker>import { MdColorPicker } from '@awc-ui/react';
export function Demo() {
return (
<>
<style>
.parts-cp::part(plate) { border-radius: 12px; }
.parts-cp::part(thumb) { border-width: 3px; }
.parts-cp::part(preview) { border-radius: 4px; outline: 2px solid var(--md-sys-color-primary); }
.parts-cp::part(label) { text-transform: uppercase; letter-spacing: .08em; font-size: 10px; }
</style>
<MdColorPicker className="parts-cp" variant="inline" value="#6750A4" aria-label="Styled parts" style={{ inlineSize: '280px' }}></MdColorPicker>
</>
);
}// app.module.ts — register the AWC UI elements once
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
import { AwcUiModule } from '@awc-ui/angular';
@NgModule({
imports: [AwcUiModule],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
export class AppModule {}
<!-- app.component.html -->
<style>
.parts-cp::part(plate) { border-radius: 12px; }
.parts-cp::part(thumb) { border-width: 3px; }
.parts-cp::part(preview) { border-radius: 4px; outline: 2px solid var(--md-sys-color-primary); }
.parts-cp::part(label) { text-transform: uppercase; letter-spacing: .08em; font-size: 10px; }
</style>
<md-color-picker class="parts-cp" variant="inline" value="#6750A4" aria-label="Styled parts" style="inline-size: 280px;"></md-color-picker><script setup>
import '@awc-ui/core/define';
</script>
<template>
<style>
.parts-cp::part(plate) { border-radius: 12px; }
.parts-cp::part(thumb) { border-width: 3px; }
.parts-cp::part(preview) { border-radius: 4px; outline: 2px solid var(--md-sys-color-primary); }
.parts-cp::part(label) { text-transform: uppercase; letter-spacing: .08em; font-size: 10px; }
</style>
<md-color-picker class="parts-cp" variant="inline" value="#6750A4" aria-label="Styled parts" style="inline-size: 280px;"></md-color-picker>
</template><script>
import '@awc-ui/core/define';
</script>
<style>
.parts-cp::part(plate) { border-radius: 12px; }
.parts-cp::part(thumb) { border-width: 3px; }
.parts-cp::part(preview) { border-radius: 4px; outline: 2px solid var(--md-sys-color-primary); }
.parts-cp::part(label) { text-transform: uppercase; letter-spacing: .08em; font-size: 10px; }
</style>
<md-color-picker class="parts-cp" variant="inline" value="#6750A4" aria-label="Styled parts" style="inline-size: 280px;"></md-color-picker>md-slider ·
md-text-field ·
md-select ·
md-chip ·
md-button
md-color-pickerTwo artefacts to give your AI agent so it generates correct UI with this component. The per-component spec answers "how do I use this exact tag?". The main-llm spec answers "which tag should I pick in the first place?".
md-color-picker spec card
Identity · when to use / when NOT · decision cues · behavioural contract · do/don't · anti-patterns · full API. Paste into your agent when you're implementing with this component.
System-prompt preamble · decision matrix · token reference · page recipes · anti-patterns. Paste into the system prompt at the start of a piece of work.