Use the directive on a native input, usually inside a Kikita field.

color-input.ts
import { KuiColorInput, KuiField } from '@kikita-labs/ui';

Keep the native input as the form source of truth and let the swatch open the picker.

Hex and OKLCH values are supported.

<div class="basic-color-input-example">
  <kui-field label="Primary seed" hint="Hex and OKLCH values are supported.">
    <input
      kuiColorInput
      value="#5b4fe0"
      autocomplete="off"
      swatchLabel="Open primary seed color picker"
    />
  </kui-field>
</div>

Set defaults.colorInput once for the application or for a subtree. Each option resolves as local input > defaults.colorInput.<option> > built-in default.

import { provideKikitaUi } from '@kikita-labs/ui';

export const appConfig: ApplicationConfig = {
  providers: [
    provideKikitaUi({
      defaults: {
        colorInput: {
          /* options below */
        },
      },
    }),
  ],
};
NameTypeDefaultDescription
size'xs' | 'sm' | 'md' | 'lg' — Component size. Takes precedence over the global defaults.size.
chevronIconKuiIconGlyph — Icon of the options toggle. Takes precedence over defaults.icons.pickerChevron. See Structural Icons.

Set any of these on the component or an ancestor to restyle one part. Each token is optional: when it is not set, the part uses the role or scale token in the default column.

NameTypeDefaultDescription
--kui-color-input-trigger-color-expandedCSS custom property--kui-color-primary-fillTrigger color, expanded
--kui-color-input-popover-colorCSS custom property--kui-color-textPopover color
--kui-color-input-picker-focus-ring-colorCSS custom property--kui-color-focusPicker focus ring color
--kui-color-input-hue-thumb-bgCSS custom property--kui-color-on-scrimHue thumb background
--kui-color-input-hue-thumb-ring-colorCSS custom property--kui-color-surfaceHue thumb ring color
--kui-color-input-thumb-shadowCSS custom propertyring and 1px 3px black 45%Color field thumb shadow
--kui-color-input-hue-thumb-shadowCSS custom property1px 3px black 45% and ringHue thumb shadow
--kui-color-input-num-label-colorCSS custom property--kui-color-text-secondaryNum label color
--kui-color-input-field-colorCSS custom property--kui-color-textField color
--kui-color-input-field-border-focusCSS custom property--kui-color-primary-fillField border color, focus
--kui-color-input-field-focus-ring-colorCSS custom property--kui-color-focusField focus ring color
--kui-color-input-preset-borderCSS custom property--kui-color-borderPreset border color
--kui-color-input-preset-focus-ring-colorCSS custom property--kui-color-focusPreset focus ring color
--kui-color-input-hue-focus-ring-colorCSS custom property--kui-color-focusHue thumb focus ring color
--kui-color-input-checker-bgCSS custom property--kui-color-surfaceChecker background
NameTypeDefaultDescription
--kui-color-input-popover-paddingCSS custom property--kui-space-3Popover padding
--kui-color-input-thumb-radiusCSS custom property--kui-radius-fullThumb corner radius
--kui-color-input-hue-track-radiusCSS custom property--kui-radius-fullHue track corner radius
--kui-color-input-hue-thumb-radiusCSS custom property--kui-radius-fullHue thumb corner radius
--kui-color-input-nums-gapCSS custom property--kui-space-2Nums gap
--kui-color-input-num-label-font-sizeCSS custom property--kui-text-xs-sizeNum label font size
--kui-color-input-field-font-sizeCSS custom property--kui-text-xs-sizeField font size
--kui-color-input-field-radiusCSS custom property--kui-radius-smField corner radius
--kui-color-input-preview-row-gapCSS custom property--kui-space-3Preview row gap
--kui-color-input-swatch-radius-lgCSS custom property--kui-radius-mdSwatch corner radius, lg
--kui-color-input-presets-gapCSS custom property--kui-space-2Presets gap
--kui-color-input-preset-radiusCSS custom property--kui-radius-smPreset corner radius

Every text the component owns (accessible names, visible words, announcements) is a typed message with an English default. Override it for the application with provideKikitaUi({ messages }), or for a subtree with provideKuiMessages.

NameTypeDefaultDescription
openPickerstring — Name of the button that opens the picker. Default Open color picker.
pickerLabelstring — Name of the lightness and chroma plane. Default Lightness and chroma.
huestring — Name of the hue slider. Default Hue.
presetKuiMessageFn<{ name: string; value: string; }> — Name of a theme seed preset. Default {name} seed: {value}.
presetPrimarystring — Preset name of the primary seed. Default Primary.
presetNeutralstring — Preset name of the neutral seed. Default Neutral.
presetSuccessstring — Preset name of the success seed. Default Success.
presetWarningstring — Preset name of the warning seed. Default Warning.
presetDangerstring — Preset name of the danger seed. Default Danger.
presetInfostring — Preset name of the info seed. Default Info.
copyValuestring — Copy button text and tooltip. Default Copy value.

Inputs verified against @kikita-labs/ui v2.0.0 public typings.

NameTypeDefaultDescription
kuiColorInputdirective-Applies Kikita color-input styling and picker affordances to a native input.
size'xs' | 'sm' | 'md' | 'lg''md'Control height matched to Kikita UI size tokens. Falls back to defaults.colorInput.size, then the parent field, then the global defaults.size.
invalidbooleanfalseApplies an error border and inherits invalid state from parent kui-field.
idstring | undefinedfield idNative input id override.
swatchLabelstring | undefinedcolorInput.openPicker messageAccessible label for the swatch button. Undefined when omitted: the rendered text comes from the colorInput.openPicker message (Open color picker).
messagesPartial<KuiColorInputMessages> | undefinedundefinedPer-instance text overrides (openPicker, pickerLabel, and the other picker labels). They win over scoped and root messages.
KuiColorInputOptionsinterface-Shape of defaults.colorInput: size and chevronIcon (takes precedence over defaults.icons.pickerChevron).

The editable value remains a native text input, while picker triggers are native buttons.

  • Use kui-field for label, hint, error, and described-by wiring.
  • Unsupported non-empty values expose invalid state on the wrapper.
  • Disabled and readonly native attributes also disable the swatch button.
  • A click anywhere on the field outside the swatch and chevron, including the padding around the text, focuses the text input and opens the picker; it never closes it, so the caret can be placed while typing.
  • A pointer user keeps the caret in the text field. A keyboard user is moved into the panel, because it renders in an overlay that Tab from the field never reaches; Escape or choosing a value returns focus to the trigger that opened it. The hue slider shows its focus on the thumb.
  • During server rendering the directive leaves the native input in place and adds the picker controls in the browser after the view is created, so Angular can hydrate the server markup.
  • Test the picker popover manually on narrow screens before releasing visual changes.

Consumer-visible changes of @kikita-labs/ui 2.0 for Color Input.

  • The class is KuiColorInput (it was KuiColorInputDirective); ng update @kikita-labs/ui renames the import.
  • The size falls back to defaults.colorInput.size, the chevron to defaults.colorInput.chevronIcon. swatchLabel is undefined when omitted and the text comes from the colorInput.openPicker message.
  • The picker is reachable from the keyboard (focus moves into the panel and returns on Escape), a click on the field padding focuses the input, and the swatch no longer shows slivers of its checker background.