← All Components
<mth-color-picker>
Form-associated color picker with HSL sliders, preset swatches, hex input, and feature-detected EyeDropper support.
When NOT to use: Use a lightweight @methane-ui/css layout class instead of a custom element when static CSS suffices.
Live Interactive Preview
Ready · interact with <mth-color-picker>, or toggle Theme, Direction (LTR/RTL), or props above.
Multi-Framework Playground & Snippets
<script type="module" src="@methane-ui/ui/color-picker"></script>
<mth-color-picker value="#2563eb"></mth-color-picker>import '@methane-ui/ui/color-picker';
import '@methane-ui/react';
export function Example() {
return <mth-color-picker value="#2563eb"></mth-color-picker>;
}<script setup lang="ts">
import '@methane-ui/ui/color-picker';
</script>
<template>
<mth-color-picker value="#2563eb"></mth-color-picker>
</template>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import '@methane-ui/ui/color-picker';
import { MthColorPickerDirective } from '@methane-ui/angular';
@Component({
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [MthColorPickerDirective],
template: `<mth-color-picker value="#2563eb"></mth-color-picker>`,
})
export class ExampleComponent {}<script lang="ts">
import '@methane-ui/ui/color-picker';
import MthColorPicker from '@methane-ui/svelte/MthColorPicker.svelte';
</script>
<MthColorPicker value="#2563eb"></MthColorPicker>Properties & Attributes
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
value | value | string | "#2563eb" | Selected hex color string (e.g. #2563eb). |
name | name | string | "" | Form field name. |
label | label | string | "" | Accessible field label. |
open | open | boolean | false | Whether the color picker popover is open. |
disabled | disabled | boolean | false | Disables interaction. |
readonly | readonly | boolean | false | Prevents changing the color value. |
required | required | boolean | false | Marks a color selection as required. |
Events
| Event | Detail Type | Description |
|---|---|---|
mth-change | { value: string } | Fired when the selected color changes. |
mth-open | { open: true } | Cancelable event fired before opening. |
mth-after-open | { open: true } | Fired after opening completes. |
mth-close | { reason: string } | Fired on close. |
mth-after-close | { reason: string } | Fired after close completes. |
APG Keyboard Matrix
| Key | Direction | When | Expected Behavior |
|---|---|---|---|
| Enter | both | Trigger or swatch button is focused | Toggles popover or selects color swatch |
| Escape | both | Color picker popover is open | Closes popover and restores focus |
Accessibility Checklist
| Category | Requirement | Verified By |
|---|---|---|
| aria | All aria-* IDREFs resolve within the same DOM root (ADR-003). | scanSameRootAria |
| focus | delegatesFocus: true with zero host internals.role (ADR-014). | lint-plugin & spec-compiler |
| contrast | Renders legible borders, focus outlines, and selection indicators under forced-colors: active. | Playwright forced-colors matrix |
| keyboard | Implements all 2 APG keyboard transitions across LTR/RTL. | mth-color-picker.spec.test.ts |
| states | Exposes ElementInternals CustomStateSet flags: :state(open), :state(disabled), :state(readonly), :state(dirty), :state(touched), :state(invalid). | Conformance suite |
| i18n | Routes 7 UI/ARIA strings through @methane-ui/core i18n catalog. | Locale context test |