Skip to content

feat(color-picker): color panel and color picker improvements - #2649

Open
rkaraivanov wants to merge 7 commits into
masterfrom
rkaraivanov/color-picker-improvements
Open

rkaraivanov wants to merge 7 commits into
masterfrom
rkaraivanov/color-picker-improvements

Conversation

@rkaraivanov

@rkaraivanov rkaraivanov commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Description

Adds igc-color-panel, the color picker surface as a standalone component (for theme editors and sidebars), and the features of the color picker plan. The picker shows the panel in its popup, so the picker gets every feature too.

New

  • igc-color-panel: the picker surface in the page. It emits igcInput and igcChange, and it is not a form control.
  • igc-color-swatch and igc-color-swatch-group: swatches in the light DOM, in labeled groups. All swatches are one listbox, with arrow keys. views and active-view switch between the gradient and the swatches.
  • The oklch format. In this format, the area is OKLCH lightness by chroma and the hue slider is the OKLCH hue. The area paints only the sRGB gamut.
  • selection-commit="confirm": changes in the popup are a draft until the user applies them.
  • contrast-against: a WCAG 2 contrast readout with AA and AAA marks.
  • Value text and color names for assistive technology, such as "120 degrees, green" and "dark vibrant blue". After a copy, the copy button shows success or failure.
  • Input mode: a clear icon (Color Picker: built-in clear button in input mode #2647) and the field part forwarding (Color Picker: expose the input-mode field as a part #2637).

Fixed

  • In Chromium and Safari, oklch(), lab(), color(), color-mix() and relative colors gave NaN channels. The picker now converts them to sRGB and clips them to the sRGB gamut.
  • Context colors (currentcolor, var(), system colors) are now invalid. Before, they turned into black or into their light value.

Changed behavior (see the Changed section of the CHANGELOG)

  • The swatch list is one tab stop, and swatches are igc-color-swatch elements.
  • A swatch without a label is named by its color name.
  • The marker keys move the marker 1 % or 10 % of the area. Before, an arrow key moved it 1 px.
  • In input mode, the picker is a block, and the text field fills its container.

Notes

  • The new strings show in English until igniteui-i18n-core ships them. They are on branch rkaraivanov/color-picker-strings in igniteui-i18n.
  • Some styles are provisional until the design team gives a design: the swatch selected mark and focus ring, the group label, the view switcher spacing, and the out-of-gamut part of the OKLCH area.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Documentation update

Related Issues

Closes #2647
Closes #2637

Testing

  • npm run test (Chromium): 7476 passed. The new specs cover the panel, the swatches, OKLCH, contrast, color names and the confirm mode, with a11y audits and fast-check property tests.
  • Color specs in Firefox and WebKit: the only failures also fail on master. They are 5 picker canvas specs that use synthetic pointer events (Firefox) and 2 external label specs (WebKit).
  • npm run lint and npm run check.
  • Visual check of the OKLCH area in light and dark themes, at 1× and 2×.

Checklist

  • My code follows the project's coding standards
  • I have tested my changes locally
  • I have updated documentation if needed
  • If I changed the public API on purpose, or its JSDoc, I have run npm run public-api:update and committed public-api.json and api-reference/
  • I have added a CHANGELOG.md entry under [Unreleased]

Modern CSS colors, such as oklch(), lab(), color() and color-mix(), now
parse into sRGB and no longer give NaN. A color that depends on its
context, such as currentcolor or var(), clears the value. The area keys
move the marker 1 % (10 % with Shift, Page Up/Down and Home/End) at any
area size.

In input mode, a clear icon shows while a color is set, with clear(),
a clear-icon slot and a part (#2647). The text field exposes the field,
input, native-input, label, prefix and suffix parts (#2637).

The new igc-color-panel is the picker surface as its own element. The
picker shows it in its popup, with the same parts and behavior. The new
igc-color-swatch and igc-color-swatch-group add swatches as light DOM
children of the panel or the picker, in labelled groups. All swatches
are one listbox with arrow, Home/End, Enter and Space keys. A swatch can
be a no-color swatch or use var(). views and active-view add a swatch
view with a view switcher.

The new strings show in English until igniteui-i18n-core ships them.
The swatch, group and switcher styles are temporary until the design is
ready.
Modern CSS colors, such as oklch(), lab(), color() and color-mix(), now
parse into sRGB and no longer give NaN. A color that depends on its
context, such as currentcolor or var(), clears the value. The area keys
move the marker 1 % (10 % with Shift, Page Up/Down and Home/End) at any
area size.

In input mode, a clear icon shows while a color is set, with clear(),
a clear-icon slot and a part (#2647). The text field exposes the field,
input, native-input, label, prefix and suffix parts (#2637).

The new igc-color-panel is the picker surface as its own element. The
picker shows it in its popup, with the same parts and behavior. The new
igc-color-swatch and igc-color-swatch-group add swatches as light DOM
children of the panel or the picker, in labelled groups. All swatches
are one listbox with arrow, Home/End, Enter and Space keys. A swatch can
be a no-color swatch or use var(). views and active-view add a swatch
view with a view switcher.

The new strings show in English until igniteui-i18n-core ships them.
The swatch, group and switcher styles are temporary until the design is
ready.
With selection-commit="confirm", changes in the popup are a draft:
value keeps its color and the picker emits no igcInput. Apply emits one
igcChange at once and closes the popup. Enter on the canvas marker, a
slider or a swatch also applies the draft; Space on a swatch only picks.
Cancel and every other close drop the draft. A write of a new color
from code also ends the draft.

A preview shows the initial color beside the draft, and a click on the
initial color restores it. The new footer slot adds content below the
color panel in both modes. New parts style the footer, the preview and
the buttons. The Apply, Cancel and Initial color strings show in
English until igniteui-i18n-core ships them, and the footer styles are
temporary until the design is ready.

The combo and the date range picker now render their Cancel and Apply
(or Done) buttons through the same shared template. Their output does
not change.
… feedback

The hue slider now gives its angle and hue name, such as
"120 degrees, green", to assistive technology. The alpha slider gives
its percentage. Both use the number format of the locale. While a color
is set, the value text of the canvas marker ends with the color name,
such as "dark vibrant blue".

The color name comes from the OKLCH lightness, chroma and hue of the
color. Lightness and chroma are compared with the most chromatic sRGB
color of the hue, so pure yellow and navy get sensible names. The words
and their order come from the resource strings. A swatch without a
label now takes its color name, with its alpha when it is not opaque,
instead of the color string.

After a copy, the copy button shows a check icon and "Copied" for one
second. After a failed copy, or where there is no clipboard, it shows
an error icon and "Copy failed". Only the latest copy shows its result.

The 25 new strings show in English until igniteui-i18n-core ships them.
The internal canvas now takes its finished value text from the panel.
In input mode, the text field took the width of its content, so the
clear icon made it 45 px wider while a color was set. Now the picker is
a block and the field fills its container, as in the date picker. The
clear icon takes its space from the text. Default mode stays inline.

Apps that use input mode get a wider field. To keep it narrow, set the
width of the picker.
With `contrast-against`, the color panel and the popup of the color
picker show the WCAG 2 contrast ratio of the color over that
background, such as "Contrast 4.54:1". They also show "pass" or "fail"
for the AA (4.5:1) and AAA (7:1) levels for normal text. A color with
alpha goes over the background, and a background with alpha goes over
white. The ratio is cut to two decimals, not rounded, so it never
shows a level that it fails.

`contrast-against` takes any CSS color. A color that depends on its
context, such as a `var()`, `currentcolor` or `light-dark()`, resolves
from the panel. The `var()` swatches now use the same resolver, so
they no longer wait for their first render. An empty or invalid color,
or an empty value, hides the readout. A server render has no readout;
it shows after hydration.

The `contrast`, `contrast-ratio`, `contrast-mark`, `pass` and `fail`
parts style the readout. Its five new strings show in English until
igniteui-i18n-core ships them, and its styles are temporary until the
design is ready.
In the oklch format, the area shows OKLCH lightness by chroma at the
OKLCH hue, and the hue slider moves the OKLCH hue on a track of cusp
colors. In the other formats, the area stays HSV.

- The area paints only the sRGB gamut, with smooth edges, and leaves
  the rest transparent. At the blue hue, the black-to-blue edge is a
  thin spike, painted as a 1 px line.
- A pick or hue change beyond the gamut edge keeps the lightness and
  cuts the chroma back to the edge.
- The color model keeps an OKLCH space. A gray keeps its hue across
  HSV and OKLCH.
- The marker has a new name and value text (2 new strings).

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Color Picker: built-in clear button in input mode Color Picker: expose the input-mode field as a part

1 participant