Skip to content

Styling & Customization

The <color-input> component supports three theme modes via the theme attribute or property:

Follows system preference via prefers-color-scheme

Value
oklch(65% 20% 280)
Color Space
oklch
Gamut
Contrast Color
View Code
<color-input value="oklch(65% 20% 280)"></color-input>
<color-input theme="auto"></color-input>
<color-input theme="light"></color-input>
<color-input theme="dark"></color-input>

Internally the component aligns its color-scheme with the chosen mode so native rendering and form control behavior fit the picker better.

Style exposed regions of the picker with ::part():

  • trigger — button that opens the picker
  • chip — color swatch inside the trigger
  • input — inline text input
  • error — parse error message
  • panel — popover surface
  • output — serialized color value in the preview
  • gamut — gamut indicator
  • controls — slider and numeric input region
  • area — 2D color area container

These parts intentionally cover the major UI regions rather than every internal node, which keeps styling flexibility without making the internal shadow DOM structure part of the public API.

If you want the element to behave more like a swatch launcher, hide the text field and enlarge the trigger:

color-input.swatch::part(input) {
display: none;
}
color-input.swatch::part(trigger) {
inline-size: 3rem;
block-size: 3rem;
}
color-input::part(panel) {
max-inline-size: min(90vw, 42rem);
}
color-input::part(area) {
border-radius: 1rem;
}

When the inline text value is invalid, the host receives data-error.

color-input[data-error]::part(input) {
border-color: oklch(62% 0.25 25);
}
color-input[data-error]::part(error) {
color: oklch(62% 0.25 25);
}

A compact swatch style, perfect for color palettes:

Prefer:

  • ::part(...) for exposed regions
  • host attributes such as [theme] and [data-error]
  • layout styles on the custom element itself

Avoid depending on undocumented internal descendants in the shadow tree.

The host element contains:

  • the trigger button
  • the inline text input wrapper
  • the popover panel

That means the easiest external customizations are usually host-level spacing plus part-level styling of the trigger, input, panel, and area.

When customizing the picker:

  • keep the trigger visibly interactive
  • preserve visible focus treatment
  • maintain readable contrast in the text field and panel
  • make sure custom panel sizes still leave enough room for the area picker and controls