# @salmonui/inputs/color-picker API reference

> 36 exported symbols of @salmonui/inputs/color-picker: 6 components, 5 functions, 19 interfaces and 6 types.

Canonical: https://salmonui.dev/docs/reference/inputs/color-picker

```ts
import { … } from '@salmonui/inputs/color-picker';
```

## Components

### ColorArea

Kind: component

Page: https://salmonui.dev/docs/reference/inputs/color-picker/ColorArea

```ts
function ColorArea(props: ColorAreaProps): ReactNode;
```

Saturation (inline axis) by brightness (block axis) of the current hue: a CSS-gradient square with a thumb and two
visually hidden range inputs, so assistive technology meets two APG
sliders. Arrow keys move along their axis (mirrored in right-to-left
content), Shift and Page keys take large steps, Home / End jump to the
ends of the focused channel. The square renders at its size on the
server; nothing is measured until a pointer press.

Props: [`ColorAreaProps`](https://salmonui.dev/docs/reference/inputs/color-picker/ColorAreaProps) (its members are the props)

### ColorField

Kind: component

Page: https://salmonui.dev/docs/reference/inputs/color-picker/ColorField

```ts
function ColorField(props: ColorFieldProps): ReactNode;
```

A text field for a color: accepts hex, `rgb()` and
`hsl()` text and parses it on blur or Enter (`parseColor`); text that
does not parse is reverted. Shows the value in `valueFormat`, a swatch
preview and the shared field parts. A hidden input with `name` submits the
value.

Props: [`ColorFieldProps`](https://salmonui.dev/docs/reference/inputs/color-picker/ColorFieldProps) (its members are the props)

### ColorPicker

Kind: component

Page: https://salmonui.dev/docs/reference/inputs/color-picker/ColorPicker

```ts
function ColorPicker(props: ColorPickerProps): ReactNode;
```

Color picker: a trigger button with
a swatch preview that opens a popover, or an inline panel. The panel
composes the parts: `ColorArea`, hue and alpha `ColorSlider`s and a
`ColorField` (mode `'area'`), or a `ColorSwatchPicker` (mode
`'swatches'`), recent colors and Apply / Cancel. The popover is a
`role="dialog"` that takes focus on open and returns it to the trigger
on close. A hidden input with `name` submits the value.

Props: [`ColorPickerProps`](https://salmonui.dev/docs/reference/inputs/color-picker/ColorPickerProps) (its members are the props)

### ColorSlider

Kind: component

Page: https://salmonui.dev/docs/reference/inputs/color-picker/ColorSlider

```ts
function ColorSlider(props: ColorSliderProps): ReactNode;
```

One channel of a color: a CSS-gradient
track with a thumb over a visually hidden range input (APG Slider).
`aria-valuetext` names the hue ("120°, green") or the opacity ("50%").
Horizontal sliders mirror in right-to-left content, keys included.

Props: [`ColorSliderProps`](https://salmonui.dev/docs/reference/inputs/color-picker/ColorSliderProps) (its members are the props)

### ColorSwatch

Kind: component

Page: https://salmonui.dev/docs/reference/inputs/color-picker/ColorSwatch

```ts
function ColorSwatch(props: ColorSwatchProps): ReactNode;
```

A color preview: `role="img"` named by the color, the
color over a checkerboard so alpha shows, or a struck-through box for no
color. Pure markup, server rendered.

Props: [`ColorSwatchProps`](https://salmonui.dev/docs/reference/inputs/color-picker/ColorSwatchProps) (its members are the props)

### ColorSwatchPicker

Kind: component

Page: https://salmonui.dev/docs/reference/inputs/color-picker/ColorSwatchPicker

```ts
function ColorSwatchPicker(props: ColorSwatchPickerProps): ReactNode;
```

A palette as an APG listbox laid out as a grid: one tab stop (roving tabindex), arrows move by cell and
row (ArrowLeft / ArrowRight mirrored in right-to-left content), Home / End
to the row ends, Ctrl+Home / Ctrl+End to the first and last swatch, Enter
or Space (or a click) selects. Groups are labelled `role="group"`s.

Props: [`ColorSwatchPickerProps`](https://salmonui.dev/docs/reference/inputs/color-picker/ColorSwatchPickerProps) (its members are the props)

## Functions

### colorName

Kind: function

Page: https://salmonui.dev/docs/reference/inputs/color-picker/colorName

```ts
function colorName(color: Color): string;
```

An English description of the color for `aria-valuetext` and swatch names
(`'dark vibrant green'`, `'light gray'`, `'transparent'`). Components take
`localeText.colorName` to replace it.

### hslColor

Kind: function

Page: https://salmonui.dev/docs/reference/inputs/color-picker/hslColor

```ts
function hslColor(h: number, s: number, l: number, a?: number): Color;
```

A color from HSL (hue 0-360, saturation and lightness 0-100) and alpha.

### hsvColor

Kind: function

Page: https://salmonui.dev/docs/reference/inputs/color-picker/hsvColor

```ts
function hsvColor(h: number, s: number, v: number, a?: number): Color;
```

A color from HSV (hue 0-360, saturation and brightness 0-100) and alpha.

### parseColor

Kind: function

Page: https://salmonui.dev/docs/reference/inputs/color-picker/parseColor

```ts
function parseColor(value: string): Color;
```

Parses `#rgb`, `#rgba`, `#rrggbb`, `#rrggbbaa`, `rgb()` / `rgba()` and
`hsl()` / `hsla()` (comma or space syntax, percentages, `deg`) and
`transparent`. Throws a `TypeError` for anything else; use the
result's `toString(format)` to convert.

### rgbColor

Kind: function

Page: https://salmonui.dev/docs/reference/inputs/color-picker/rgbColor

```ts
function rgbColor(r: number, g: number, b: number, a?: number): Color;
```

A color from RGB (0-255) and alpha (0-1).

## Interfaces

### Color

Kind: interface

Page: https://salmonui.dev/docs/reference/inputs/color-picker/Color

```ts
interface Color {
    readonly hue: number;
    readonly saturation: number;
    readonly brightness: number;
    readonly alpha: number;
    toRgb(): {
        readonly r: number;
        readonly g: number;
        readonly b: number;
        readonly a: number;
    };
    toHsl(): {
        readonly h: number;
        readonly s: number;
        readonly l: number;
        readonly a: number;
    };
    toHsv(): {
        readonly h: number;
        readonly s: number;
        readonly v: number;
        readonly a: number;
    };
    toString(format?: ColorFormat): string;
    with(channels: {
        readonly hue?: number;
        readonly saturation?: number;
        readonly brightness?: number;
        readonly alpha?: number;
    }): Color;
    equals(other: Color | null | undefined, format?: ColorFormat): boolean;
}
```

An immutable color. Channels: hue 0-360, saturation / brightness / lightness 0-100, alpha 0-1, rgb 0-255.

Members (10):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `hue` | `readonly hue: number;` |  | HSV hue, 0-360. |
| `saturation` | `readonly saturation: number;` |  | HSV saturation, 0-100. |
| `brightness` | `readonly brightness: number;` |  | HSV brightness (value), 0-100. |
| `alpha` | `readonly alpha: number;` |  | Alpha, 0-1. |
| `toRgb` | `toRgb(): {     readonly r: number;     readonly g: number;     readonly b: number;     readonly a: number; };` |  |  |
| `toHsl` | `toHsl(): {     readonly h: number;     readonly s: number;     readonly l: number;     readonly a: number; };` |  |  |
| `toHsv` | `toHsv(): {     readonly h: number;     readonly s: number;     readonly v: number;     readonly a: number; };` |  |  |
| `toString` | `toString(format?: ColorFormat): string;` |  | `'hex'` `#rrggbb`, `'hexa'` `#rrggbbaa` (default), `'rgb'` `rgb()` / `rgba()`, `'hsl'` `hsl()` / `hsla()`. |
| `with` | `with(channels: {     readonly hue?: number;     readonly saturation?: number;     readonly brightness?: number;     readonly alpha?: number; }): Color;` |  | A copy with some HSV channels or alpha replaced. |
| `equals` | `equals(other: Color \| null \| undefined, format?: ColorFormat): boolean;` |  | True when both serialize to the same `format` (default `'hexa'`). |

### ColorAreaProps

Kind: interface

Page: https://salmonui.dev/docs/reference/inputs/color-picker/ColorAreaProps

```ts
interface ColorAreaProps extends ColorPartProps {
    readonly step?: number | undefined;
    readonly ref?: Ref<HTMLDivElement> | undefined;
}
```

Members (16):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `step` | `readonly step?: number \| undefined;` | optional | Step of the arrow keys in percent; Shift and Page keys use ten times it. Default 1. |
| `ref` | `readonly ref?: Ref<HTMLDivElement> \| undefined;` | optional | The root element. |
| `value` | `value?: ColorInput;` | optional, inherited | Controlled color: a string or a `Color` (a `Color` keeps the hue of grays). |
| `defaultValue` | `defaultValue?: ColorInput;` | optional, inherited |  |
| `onValueChange` | `onValueChange?: ((color: Color, details: ColorChangeDetails) => void);` | optional, inherited | Every change; during a pointer drag at most once per animation frame. |
| `onValueCommit` | `onValueCommit?: ((color: Color, details: ColorChangeDetails) => void);` | optional, inherited | The end of a drag, and every keyboard step. |
| `name` | `name?: string;` | optional, inherited | Name of a hidden input carrying the color in `valueFormat`. |
| `form` | `form?: string;` | optional, inherited |  |
| `valueFormat` | `valueFormat?: ColorFormat;` | optional, inherited | Format of the hidden input value. Default `'hexa'`. |
| `disabled` | `disabled?: boolean;` | optional, inherited |  |
| `localeText` | `localeText?: ColorPartLocaleText;` | optional, inherited |  |
| `className` | `className?: string;` | optional, inherited |  |
| `style` | `style?: CSSProperties;` | optional, inherited |  |
| `aria-label` | `aria-label?: string;` | optional, inherited |  |
| `aria-labelledby` | `aria-labelledby?: string;` | optional, inherited |  |
| `id` | `id?: string;` | optional, inherited |  |

### ColorChangeDetails

Kind: interface

Page: https://salmonui.dev/docs/reference/inputs/color-picker/ColorChangeDetails

```ts
interface ColorChangeDetails {
    readonly source: ColorChangeSource;
    readonly reason: 'drag' | 'step' | 'reset';
}
```

Second argument of `onValueChange` / `onValueCommit` of ColorArea and ColorSlider.

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `source` | `readonly source: ColorChangeSource;` |  |  |
| `reason` | `readonly reason: 'drag' \| 'step' \| 'reset';` |  | `'drag'` pointer drag (rAF-throttled), `'step'` keyboard or assistive technology step, `'reset'` form reset. |

### ColorFieldChangeDetails

Kind: interface

Page: https://salmonui.dev/docs/reference/inputs/color-picker/ColorFieldChangeDetails

```ts
interface ColorFieldChangeDetails {
    readonly source: ColorChangeSource;
    readonly reason: 'input' | 'clear' | 'reset';
    readonly color: Color | null;
}
```

Second argument of ColorField `onValueChange`.

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `source` | `readonly source: ColorChangeSource;` |  |  |
| `reason` | `readonly reason: 'input' \| 'clear' \| 'reset';` |  | `'input'` a parsed entry (blur or Enter), `'clear'` clear button, Escape or an emptied field, `'reset'` form reset. |
| `color` | `readonly color: Color \| null;` |  |  |

### ColorFieldProps

Kind: interface

Page: https://salmonui.dev/docs/reference/inputs/color-picker/ColorFieldProps

```ts
interface ColorFieldProps extends FieldCommonProps, NativeInput {
    readonly value?: ColorInput | null | undefined;
    readonly defaultValue?: ColorInput | null | undefined;
    readonly onValueChange?: ((value: string | null, details: ColorFieldChangeDetails) => void) | undefined;
    readonly valueFormat?: ColorFormat | undefined;
    readonly clearable?: boolean | undefined;
    readonly showSwatch?: boolean | undefined;
    readonly endAdornment?: ReactNode;
    readonly localeText?: (FieldValidationText & {
        readonly clear?: string;
        readonly colorName?: (color: Color) => string;
    }) | undefined;
    readonly className?: string | undefined;
    readonly style?: CSSProperties | undefined;
    readonly classNames?: {
        readonly group?: string;
        readonly input?: string;
        readonly label?: string;
        readonly description?: string;
        readonly error?: string;
    } | undefined;
    readonly ref?: Ref<HTMLInputElement> | undefined;
}
```

Members (19):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `value` | `readonly value?: ColorInput \| null \| undefined;` | optional |  |
| `defaultValue` | `readonly defaultValue?: ColorInput \| null \| undefined;` | optional |  |
| `onValueChange` | `readonly onValueChange?: ((value: string \| null, details: ColorFieldChangeDetails) => void) \| undefined;` | optional | Called with the entry in `valueFormat` after it parses (blur or Enter), or null when emptied. |
| `valueFormat` | `readonly valueFormat?: ColorFormat \| undefined;` | optional | Format of the shown and reported value. Default `'hexa'`. |
| `clearable` | `readonly clearable?: boolean \| undefined;` | optional |  |
| `showSwatch` | `readonly showSwatch?: boolean \| undefined;` | optional | A `ColorSwatch` of the value as the start adornment. Default true. |
| `endAdornment` | `readonly endAdornment?: ReactNode;` | optional |  |
| `localeText` | `readonly localeText?: (FieldValidationText & {     readonly clear?: string;     readonly colorName?: (color: Color) => string; }) \| undefined;` | optional |  |
| `className` | `readonly className?: string \| undefined;` | optional |  |
| `style` | `readonly style?: CSSProperties \| undefined;` | optional |  |
| `classNames` | `readonly classNames?: {     readonly group?: string;     readonly input?: string;     readonly label?: string;     readonly description?: string;     readonly error?: string; } \| undefined;` | optional |  |
| `ref` | `readonly ref?: Ref<HTMLInputElement> \| undefined;` | optional | The native `<input>`. |
| `label` | `label?: ReactNode;` | optional, inherited |  |
| `description` | `description?: ReactNode;` | optional, inherited |  |
| `errorMessage` | `errorMessage?: ((ctx: { readonly errors: readonly string[]; }) => ReactNode) \| ReactNode;` | optional, inherited | Error text (or a function of the errors) shown while the field is invalid. |
| `invalid` | `invalid?: boolean;` | optional, inherited | Forces the error state. |
| `validation` | `validation?: FieldValidation;` | optional, inherited | Rules in the Data Grid vocabulary. |
| `validateOn` | `validateOn?: ValidateOn;` | optional, inherited | When errors appear; default the `Form`'s, else `'blur'`. |
| `size` | `size?: FieldSize;` | optional, inherited | Metric set. Default `'md'`. |

### ColorPartLocaleText

Kind: interface

Page: https://salmonui.dev/docs/reference/inputs/color-picker/ColorPartLocaleText

```ts
interface ColorPartLocaleText {
    readonly saturation?: string;
    readonly brightness?: string;
    readonly hue?: string;
    readonly alpha?: string;
    readonly colorName?: (color: Color) => string;
    readonly hueName?: (hue: number) => string;
}
```

Strings of the color parts; `colorName` and `hueName` replace the English descriptions in `aria-valuetext`.

Members (6):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `saturation` | `readonly saturation?: string;` | optional |  |
| `brightness` | `readonly brightness?: string;` | optional |  |
| `hue` | `readonly hue?: string;` | optional |  |
| `alpha` | `readonly alpha?: string;` | optional |  |
| `colorName` | `readonly colorName?: (color: Color) => string;` | optional |  |
| `hueName` | `readonly hueName?: (hue: number) => string;` | optional | Name of a hue (0-360 degrees) in the hue slider's `aria-valuetext` ("120°, green"). |

### ColorPartProps

Kind: interface

Page: https://salmonui.dev/docs/reference/inputs/color-picker/ColorPartProps

```ts
interface ColorPartProps {
    readonly value?: ColorInput | undefined;
    readonly defaultValue?: ColorInput | undefined;
    readonly onValueChange?: ((color: Color, details: ColorChangeDetails) => void) | undefined;
    readonly onValueCommit?: ((color: Color, details: ColorChangeDetails) => void) | undefined;
    readonly name?: string | undefined;
    readonly form?: string | undefined;
    readonly valueFormat?: ColorFormat | undefined;
    readonly disabled?: boolean | undefined;
    readonly localeText?: ColorPartLocaleText | undefined;
    readonly className?: string | undefined;
    readonly style?: CSSProperties | undefined;
    readonly 'aria-label'?: string | undefined;
    readonly 'aria-labelledby'?: string | undefined;
    readonly id?: string | undefined;
}
```

Props shared by ColorArea and ColorSlider.

Members (14):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `value` | `readonly value?: ColorInput \| undefined;` | optional | Controlled color: a string or a `Color` (a `Color` keeps the hue of grays). |
| `defaultValue` | `readonly defaultValue?: ColorInput \| undefined;` | optional |  |
| `onValueChange` | `readonly onValueChange?: ((color: Color, details: ColorChangeDetails) => void) \| undefined;` | optional | Every change; during a pointer drag at most once per animation frame. |
| `onValueCommit` | `readonly onValueCommit?: ((color: Color, details: ColorChangeDetails) => void) \| undefined;` | optional | The end of a drag, and every keyboard step. |
| `name` | `readonly name?: string \| undefined;` | optional | Name of a hidden input carrying the color in `valueFormat`. |
| `form` | `readonly form?: string \| undefined;` | optional |  |
| `valueFormat` | `readonly valueFormat?: ColorFormat \| undefined;` | optional | Format of the hidden input value. Default `'hexa'`. |
| `disabled` | `readonly disabled?: boolean \| undefined;` | optional |  |
| `localeText` | `readonly localeText?: ColorPartLocaleText \| undefined;` | optional |  |
| `className` | `readonly className?: string \| undefined;` | optional |  |
| `style` | `readonly style?: CSSProperties \| undefined;` | optional |  |
| `aria-label` | `readonly 'aria-label'?: string \| undefined;` | optional |  |
| `aria-labelledby` | `readonly 'aria-labelledby'?: string \| undefined;` | optional |  |
| `id` | `readonly id?: string \| undefined;` | optional |  |

### ColorPickerBeforeModeChangeEvent

Kind: interface

Page: https://salmonui.dev/docs/reference/inputs/color-picker/ColorPickerBeforeModeChangeEvent

```ts
interface ColorPickerBeforeModeChangeEvent extends ColorPickerCancelableEvent {
    readonly mode: ColorPickerMode;
}
```

Argument of `onBeforeModeChange`.

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `mode` | `readonly mode: ColorPickerMode;` |  |  |
| `defaultPrevented` | `defaultPrevented: boolean;` | inherited |  |
| `preventDefault` | `preventDefault: () => void;` | inherited |  |

### ColorPickerBeforeOpenChangeEvent

Kind: interface

Page: https://salmonui.dev/docs/reference/inputs/color-picker/ColorPickerBeforeOpenChangeEvent

```ts
interface ColorPickerBeforeOpenChangeEvent extends ColorPickerCancelableEvent, ColorPickerOpenChangeDetails {
    readonly open: boolean;
}
```

Argument of `onBeforeOpenChange`.

Members (5):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `open` | `readonly open: boolean;` |  |  |
| `source` | `source: ColorChangeSource;` | inherited |  |
| `reason` | `reason: "apply" \| "cancel" \| "escape" \| "focus-outside" \| "outside" \| "select" \| "trigger";` | inherited |  |
| `defaultPrevented` | `defaultPrevented: boolean;` | inherited |  |
| `preventDefault` | `preventDefault: () => void;` | inherited |  |

### ColorPickerCancelableEvent

Kind: interface

Page: https://salmonui.dev/docs/reference/inputs/color-picker/ColorPickerCancelableEvent

```ts
interface ColorPickerCancelableEvent {
    readonly defaultPrevented: boolean;
    preventDefault(): void;
}
```

A cancellable event: `preventDefault()` vetoes the change.

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `defaultPrevented` | `readonly defaultPrevented: boolean;` |  |  |
| `preventDefault` | `preventDefault(): void;` |  |  |

### ColorPickerChangeDetails

Kind: interface

Page: https://salmonui.dev/docs/reference/inputs/color-picker/ColorPickerChangeDetails

```ts
interface ColorPickerChangeDetails {
    readonly source: ColorChangeSource;
    readonly reason: 'area' | 'hue' | 'alpha' | 'field' | 'swatch' | 'recent' | 'clear' | 'apply' | 'cancel' | 'reset';
    readonly color: Color | null;
}
```

Second argument of `onValueChange` and `onValueCommit`.

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `source` | `readonly source: ColorChangeSource;` |  |  |
| `reason` | `readonly reason: 'area' \| 'hue' \| 'alpha' \| 'field' \| 'swatch' \| 'recent' \| 'clear' \| 'apply' \| 'cancel' \| 'reset';` |  | The part that changed the color; `'apply'` the Apply button (commit only), `'cancel'` a discarded pick, `'reset'` form reset. |
| `color` | `readonly color: Color \| null;` |  |  |

### ColorPickerOpenChangeDetails

Kind: interface

Page: https://salmonui.dev/docs/reference/inputs/color-picker/ColorPickerOpenChangeDetails

```ts
interface ColorPickerOpenChangeDetails {
    readonly source: ColorChangeSource;
    readonly reason: 'trigger' | 'escape' | 'outside' | 'focus-outside' | 'apply' | 'cancel' | 'select';
}
```

Second argument of `onOpenChange`.

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `source` | `readonly source: ColorChangeSource;` |  |  |
| `reason` | `readonly reason: 'trigger' \| 'escape' \| 'outside' \| 'focus-outside' \| 'apply' \| 'cancel' \| 'select';` |  |  |

### ColorPickerProps

Kind: interface

Page: https://salmonui.dev/docs/reference/inputs/color-picker/ColorPickerProps

```ts
interface ColorPickerProps extends FieldCommonProps {
    readonly value?: string | null | undefined;
    readonly defaultValue?: string | null | undefined;
    readonly onValueChange?: ((value: string | null, details: ColorPickerChangeDetails) => void) | undefined;
    readonly onValueCommit?: ((value: string | null, details: ColorPickerChangeDetails) => void) | undefined;
    readonly valueFormat?: ColorFormat | undefined;
    readonly mode?: ColorPickerMode | undefined;
    readonly defaultMode?: ColorPickerMode | undefined;
    readonly onModeChange?: ((mode: ColorPickerMode) => void) | undefined;
    readonly onBeforeModeChange?: ((event: ColorPickerBeforeModeChangeEvent) => void) | undefined;
    readonly showModeSwitch?: boolean | undefined;
    readonly inline?: boolean | undefined;
    readonly alpha?: boolean | undefined;
    readonly clearable?: boolean | undefined;
    readonly commitBehavior?: 'confirm' | 'immediate' | undefined;
    readonly recentColors?: readonly string[] | undefined;
    readonly defaultRecentColors?: readonly string[] | undefined;
    readonly onRecentColorsChange?: ((colors: readonly string[]) => void) | undefined;
    readonly maxRecentColors?: number | undefined;
    readonly colors?: readonly ColorSwatchItem[] | readonly ColorSwatchGroup[] | undefined;
    readonly columns?: number | undefined;
    readonly renderSwatch?: ((ctx: SwatchRenderContext) => ReactNode) | undefined;
    readonly open?: boolean | undefined;
    readonly defaultOpen?: boolean | undefined;
    readonly onOpenChange?: ((open: boolean, details: ColorPickerOpenChangeDetails) => void) | undefined;
    readonly onBeforeOpenChange?: ((event: ColorPickerBeforeOpenChangeEvent) => void) | undefined;
    readonly name?: string | undefined;
    readonly form?: string | undefined;
    readonly disabled?: boolean | undefined;
    readonly required?: boolean | undefined;
    readonly id?: string | undefined;
    readonly 'aria-label'?: string | undefined;
    readonly localeText?: ColorPickerLocaleText | undefined;
    readonly className?: string | undefined;
    readonly style?: CSSProperties | undefined;
    readonly ref?: Ref<HTMLElement> | undefined;
}
```

Members (42):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `label` | `label?: ReactNode;` | optional, inherited |  |
| `description` | `description?: ReactNode;` | optional, inherited |  |
| `errorMessage` | `errorMessage?: ((ctx: { readonly errors: readonly string[]; }) => ReactNode) \| ReactNode;` | optional, inherited | Error text (or a function of the errors) shown while the field is invalid. |
| `invalid` | `invalid?: boolean;` | optional, inherited | Forces the error state. |
| `validation` | `validation?: FieldValidation;` | optional, inherited | Rules in the Data Grid vocabulary. |
| `validateOn` | `validateOn?: ValidateOn;` | optional, inherited | When errors appear; default the `Form`'s, else `'blur'`. |
| `size` | `size?: FieldSize;` | optional, inherited | Metric set. Default `'md'`. |
| `value` | `readonly value?: string \| null \| undefined;` | optional | The color in `valueFormat`, or null for no color. |
| `defaultValue` | `readonly defaultValue?: string \| null \| undefined;` | optional | Default `'#008000ff'`. |
| `onValueChange` | `readonly onValueChange?: ((value: string \| null, details: ColorPickerChangeDetails) => void) \| undefined;` | optional | Every pick, at most once per animation frame while dragging. |
| `onValueCommit` | `readonly onValueCommit?: ((value: string \| null, details: ColorPickerChangeDetails) => void) \| undefined;` | optional | A committed value: Apply with `commitBehavior: 'confirm'`, else a drag end, key step, field entry or swatch pick. |
| `valueFormat` | `readonly valueFormat?: ColorFormat \| undefined;` | optional | Default `'hexa'`. With `'hex'` the alpha slider is hidden. |
| `mode` | `readonly mode?: ColorPickerMode \| undefined;` | optional |  |
| `defaultMode` | `readonly defaultMode?: ColorPickerMode \| undefined;` | optional | Default `'area'`. |
| `onModeChange` | `readonly onModeChange?: ((mode: ColorPickerMode) => void) \| undefined;` | optional |  |
| `onBeforeModeChange` | `readonly onBeforeModeChange?: ((event: ColorPickerBeforeModeChangeEvent) => void) \| undefined;` | optional | Cancellable. |
| `showModeSwitch` | `readonly showModeSwitch?: boolean \| undefined;` | optional | The button that switches between the area and the palette. Default true. |
| `inline` | `readonly inline?: boolean \| undefined;` | optional | Renders the panel in place, without a trigger or popover. |
| `alpha` | `readonly alpha?: boolean \| undefined;` | optional | The alpha slider and alpha in the hex field. Default true. |
| `clearable` | `readonly clearable?: boolean \| undefined;` | optional | A "no color" swatch (and the field's clear button); value null. |
| `commitBehavior` | `readonly commitBehavior?: 'confirm' \| 'immediate' \| undefined;` | optional | `'confirm'` (default): Apply and Cancel buttons, Cancel or a dismissal discards the picks. `'immediate'`: every pick commits. |
| `recentColors` | `readonly recentColors?: readonly string[] \| undefined;` | optional | Recently committed colors, newest first. Shown and tracked when this or `defaultRecentColors` is set; never stored. |
| `defaultRecentColors` | `readonly defaultRecentColors?: readonly string[] \| undefined;` | optional |  |
| `onRecentColorsChange` | `readonly onRecentColorsChange?: ((colors: readonly string[]) => void) \| undefined;` | optional |  |
| `maxRecentColors` | `readonly maxRecentColors?: number \| undefined;` | optional | Default 10. |
| `colors` | `readonly colors?: readonly ColorSwatchItem[] \| readonly ColorSwatchGroup[] \| undefined;` | optional | Palette of the swatches mode; default the `ColorSwatchPicker` palette. |
| `columns` | `readonly columns?: number \| undefined;` | optional | Palette columns. Default 10. |
| `renderSwatch` | `readonly renderSwatch?: ((ctx: SwatchRenderContext) => ReactNode) \| undefined;` | optional | Replaces each palette swatch. |
| `open` | `readonly open?: boolean \| undefined;` | optional |  |
| `defaultOpen` | `readonly defaultOpen?: boolean \| undefined;` | optional |  |
| `onOpenChange` | `readonly onOpenChange?: ((open: boolean, details: ColorPickerOpenChangeDetails) => void) \| undefined;` | optional |  |
| `onBeforeOpenChange` | `readonly onBeforeOpenChange?: ((event: ColorPickerBeforeOpenChangeEvent) => void) \| undefined;` | optional | Cancellable. |
| `name` | `readonly name?: string \| undefined;` | optional | Name of a hidden input carrying the value (`''` for no color). |
| `form` | `readonly form?: string \| undefined;` | optional |  |
| `disabled` | `readonly disabled?: boolean \| undefined;` | optional |  |
| `required` | `readonly required?: boolean \| undefined;` | optional |  |
| `id` | `readonly id?: string \| undefined;` | optional |  |
| `aria-label` | `readonly 'aria-label'?: string \| undefined;` | optional | Accessible name of the trigger without a `label`. |
| `localeText` | `readonly localeText?: ColorPickerLocaleText \| undefined;` | optional |  |
| `className` | `readonly className?: string \| undefined;` | optional |  |
| `style` | `readonly style?: CSSProperties \| undefined;` | optional |  |
| `ref` | `readonly ref?: Ref<HTMLElement> \| undefined;` | optional | The trigger button (the panel group when `inline`). |

### ColorSliderProps

Kind: interface

Page: https://salmonui.dev/docs/reference/inputs/color-picker/ColorSliderProps

```ts
interface ColorSliderProps extends ColorPartProps {
    readonly channel: 'hue' | 'alpha';
    readonly orientation?: 'horizontal' | 'vertical' | undefined;
    readonly step?: number | undefined;
    readonly ref?: Ref<HTMLDivElement> | undefined;
}
```

Members (18):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `channel` | `readonly channel: 'hue' \| 'alpha';` |  | The channel: `'hue'` (0-360 degrees) or `'alpha'` (0-100 percent). |
| `orientation` | `readonly orientation?: 'horizontal' \| 'vertical' \| undefined;` | optional | Default `'horizontal'`; vertical sliders grow upward and never mirror. |
| `step` | `readonly step?: number \| undefined;` | optional | Arrow key step in channel units; Shift and Page keys use ten times it. Default 1. |
| `ref` | `readonly ref?: Ref<HTMLDivElement> \| undefined;` | optional | The root element. |
| `value` | `value?: ColorInput;` | optional, inherited | Controlled color: a string or a `Color` (a `Color` keeps the hue of grays). |
| `defaultValue` | `defaultValue?: ColorInput;` | optional, inherited |  |
| `onValueChange` | `onValueChange?: ((color: Color, details: ColorChangeDetails) => void);` | optional, inherited | Every change; during a pointer drag at most once per animation frame. |
| `onValueCommit` | `onValueCommit?: ((color: Color, details: ColorChangeDetails) => void);` | optional, inherited | The end of a drag, and every keyboard step. |
| `name` | `name?: string;` | optional, inherited | Name of a hidden input carrying the color in `valueFormat`. |
| `form` | `form?: string;` | optional, inherited |  |
| `valueFormat` | `valueFormat?: ColorFormat;` | optional, inherited | Format of the hidden input value. Default `'hexa'`. |
| `disabled` | `disabled?: boolean;` | optional, inherited |  |
| `localeText` | `localeText?: ColorPartLocaleText;` | optional, inherited |  |
| `className` | `className?: string;` | optional, inherited |  |
| `style` | `style?: CSSProperties;` | optional, inherited |  |
| `aria-label` | `aria-label?: string;` | optional, inherited |  |
| `aria-labelledby` | `aria-labelledby?: string;` | optional, inherited |  |
| `id` | `id?: string;` | optional, inherited |  |

### ColorSwatchGroup

Kind: interface

Page: https://salmonui.dev/docs/reference/inputs/color-picker/ColorSwatchGroup

```ts
interface ColorSwatchGroup {
    readonly label: string;
    readonly colors: readonly ColorSwatchItem[];
}
```

A labelled group of palette entries.

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `label` | `readonly label: string;` |  |  |
| `colors` | `readonly colors: readonly ColorSwatchItem[];` |  |  |

### ColorSwatchPickerProps

Kind: interface

Page: https://salmonui.dev/docs/reference/inputs/color-picker/ColorSwatchPickerProps

```ts
interface ColorSwatchPickerProps {
    readonly colors?: readonly ColorSwatchItem[] | readonly ColorSwatchGroup[] | undefined;
    readonly columns?: number | undefined;
    readonly value?: string | null | undefined;
    readonly defaultValue?: string | null | undefined;
    readonly onValueChange?: ((value: string | null, details: SwatchChangeDetails) => void) | undefined;
    readonly clearable?: boolean | undefined;
    readonly renderSwatch?: ((ctx: SwatchRenderContext) => ReactNode) | undefined;
    readonly name?: string | undefined;
    readonly form?: string | undefined;
    readonly disabled?: boolean | undefined;
    readonly localeText?: {
        readonly noColor?: string;
        readonly colorName?: (color: Color) => string;
    } | undefined;
    readonly className?: string | undefined;
    readonly style?: CSSProperties | undefined;
    readonly id?: string | undefined;
    readonly 'aria-label'?: string | undefined;
    readonly 'aria-labelledby'?: string | undefined;
    readonly ref?: Ref<HTMLDivElement> | undefined;
}
```

Members (17):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `colors` | `readonly colors?: readonly ColorSwatchItem[] \| readonly ColorSwatchGroup[] \| undefined;` | optional | Flat entries or labelled groups. Default: a 10-column palette of grays and 9 hues in 5 shades. |
| `columns` | `readonly columns?: number \| undefined;` | optional | Swatches per row. Default 10. |
| `value` | `readonly value?: string \| null \| undefined;` | optional |  |
| `defaultValue` | `readonly defaultValue?: string \| null \| undefined;` | optional |  |
| `onValueChange` | `readonly onValueChange?: ((value: string \| null, details: SwatchChangeDetails) => void) \| undefined;` | optional |  |
| `clearable` | `readonly clearable?: boolean \| undefined;` | optional | Adds a "no color" swatch first; picking it sets `null`. |
| `renderSwatch` | `readonly renderSwatch?: ((ctx: SwatchRenderContext) => ReactNode) \| undefined;` | optional | Replaces the swatch inside each option. |
| `name` | `readonly name?: string \| undefined;` | optional | Name of a hidden input carrying the value (`''` for no color). |
| `form` | `readonly form?: string \| undefined;` | optional |  |
| `disabled` | `readonly disabled?: boolean \| undefined;` | optional |  |
| `localeText` | `readonly localeText?: {     readonly noColor?: string;     readonly colorName?: (color: Color) => string; } \| undefined;` | optional |  |
| `className` | `readonly className?: string \| undefined;` | optional |  |
| `style` | `readonly style?: CSSProperties \| undefined;` | optional |  |
| `id` | `readonly id?: string \| undefined;` | optional |  |
| `aria-label` | `readonly 'aria-label'?: string \| undefined;` | optional |  |
| `aria-labelledby` | `readonly 'aria-labelledby'?: string \| undefined;` | optional |  |
| `ref` | `readonly ref?: Ref<HTMLDivElement> \| undefined;` | optional | The listbox element. |

### ColorSwatchProps

Kind: interface

Page: https://salmonui.dev/docs/reference/inputs/color-picker/ColorSwatchProps

```ts
interface ColorSwatchProps {
    readonly color: ColorInput | null;
    readonly 'aria-label'?: string | undefined;
    readonly colorName?: ((color: Color) => string) | undefined;
    readonly id?: string | undefined;
    readonly className?: string | undefined;
    readonly style?: CSSProperties | undefined;
}
```

Members (6):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `color` | `readonly color: ColorInput \| null;` |  | The color; `null` draws the "no color" swatch. |
| `aria-label` | `readonly 'aria-label'?: string \| undefined;` | optional | Accessible name; default the color's description (`'dark vibrant green'`) or `'No color'`. Pass `''` to make it decorative. |
| `colorName` | `readonly colorName?: ((color: Color) => string) \| undefined;` | optional | Replaces the English description when no `aria-label` is given. |
| `id` | `readonly id?: string \| undefined;` | optional |  |
| `className` | `readonly className?: string \| undefined;` | optional |  |
| `style` | `readonly style?: CSSProperties \| undefined;` | optional |  |

### SwatchChangeDetails

Kind: interface

Page: https://salmonui.dev/docs/reference/inputs/color-picker/SwatchChangeDetails

```ts
interface SwatchChangeDetails {
    readonly source: ColorChangeSource;
    readonly reason: 'select' | 'reset';
    readonly color: Color | null;
}
```

Second argument of `onValueChange`.

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `source` | `readonly source: ColorChangeSource;` |  |  |
| `reason` | `readonly reason: 'select' \| 'reset';` |  |  |
| `color` | `readonly color: Color \| null;` |  | The picked color (null for "no color"). |

### SwatchRenderContext

Kind: interface

Page: https://salmonui.dev/docs/reference/inputs/color-picker/SwatchRenderContext

```ts
interface SwatchRenderContext {
    readonly color: Color | null;
    readonly value: string | null;
    readonly label: string;
    readonly selected: boolean;
    readonly index: number;
}
```

Argument of `renderSwatch`.

Members (5):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `color` | `readonly color: Color \| null;` |  |  |
| `value` | `readonly value: string \| null;` |  |  |
| `label` | `readonly label: string;` |  |  |
| `selected` | `readonly selected: boolean;` |  |  |
| `index` | `readonly index: number;` |  |  |

## Types

### ColorChangeSource

Kind: type

Page: https://salmonui.dev/docs/reference/inputs/color-picker/ColorChangeSource

```ts
type ColorChangeSource = 'pointer' | 'keyboard' | 'touch' | 'api';
```

Where a change came from.

### ColorFormat

Kind: type

Page: https://salmonui.dev/docs/reference/inputs/color-picker/ColorFormat

```ts
type ColorFormat = 'hex' | 'hexa' | 'rgb' | 'hsl';
```

Serialization formats of a color value.

### ColorInput

Kind: type

Page: https://salmonui.dev/docs/reference/inputs/color-picker/ColorInput

```ts
type ColorInput = string | Color;
```

A value prop of the color components: a color string or a `Color`.

### ColorPickerLocaleText

Kind: type

Page: https://salmonui.dev/docs/reference/inputs/color-picker/ColorPickerLocaleText

```ts
type ColorPickerLocaleText = FieldValidationText & ColorPartLocaleText & {
    readonly trigger?: string;
    readonly dialog?: string;
    readonly area?: string;
    readonly colors?: string;
    readonly recentColors?: string;
    readonly noColor?: string;
    readonly apply?: string;
    readonly cancel?: string;
    readonly current?: string;
    readonly previous?: string;
    readonly clear?: string;
    readonly hex?: string;
    readonly switchToSwatches?: string;
    readonly switchToArea?: string;
};
```

User-visible strings of ColorPicker.

Members (37):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `validationCreditcard` | `validationCreditcard?: string;` | optional, inherited |  |
| `validationDate` | `validationDate?: string;` | optional, inherited |  |
| `validationDateIso` | `validationDateIso?: string;` | optional, inherited |  |
| `validationDigits` | `validationDigits?: string;` | optional, inherited |  |
| `validationEmail` | `validationEmail?: string;` | optional, inherited |  |
| `validationMax` | `validationMax?: string;` | optional, inherited |  |
| `validationMaxLength` | `validationMaxLength?: string;` | optional, inherited |  |
| `validationMin` | `validationMin?: string;` | optional, inherited |  |
| `validationMinLength` | `validationMinLength?: string;` | optional, inherited |  |
| `validationNumber` | `validationNumber?: string;` | optional, inherited |  |
| `validationPattern` | `validationPattern?: string;` | optional, inherited |  |
| `validationRange` | `validationRange?: string;` | optional, inherited |  |
| `validationRangeLength` | `validationRangeLength?: string;` | optional, inherited |  |
| `validationRequired` | `validationRequired?: string;` | optional, inherited |  |
| `validationTel` | `validationTel?: string;` | optional, inherited |  |
| `validationUrl` | `validationUrl?: string;` | optional, inherited |  |
| `validationValidate` | `validationValidate?: string;` | optional, inherited |  |
| `saturation` | `saturation?: string;` | optional, inherited |  |
| `brightness` | `brightness?: string;` | optional, inherited |  |
| `hue` | `hue?: string;` | optional, inherited |  |
| `alpha` | `alpha?: string;` | optional, inherited |  |
| `colorName` | `colorName?: ((color: Color) => string);` | optional, inherited |  |
| `hueName` | `hueName?: ((hue: number) => string);` | optional, inherited | Name of a hue (0-360 degrees) in the hue slider's `aria-valuetext` ("120°, green"). |
| `trigger` | `trigger?: string;` | optional, inherited |  |
| `dialog` | `dialog?: string;` | optional, inherited |  |
| `area` | `area?: string;` | optional, inherited |  |
| `colors` | `colors?: string;` | optional, inherited |  |
| `recentColors` | `recentColors?: string;` | optional, inherited |  |
| `noColor` | `noColor?: string;` | optional, inherited |  |
| `apply` | `apply?: string;` | optional, inherited |  |
| `cancel` | `cancel?: string;` | optional, inherited |  |
| `current` | `current?: string;` | optional, inherited |  |
| `previous` | `previous?: string;` | optional, inherited |  |
| `clear` | `clear?: string;` | optional, inherited |  |
| `hex` | `hex?: string;` | optional, inherited |  |
| `switchToSwatches` | `switchToSwatches?: string;` | optional, inherited |  |
| `switchToArea` | `switchToArea?: string;` | optional, inherited |  |

### ColorPickerMode

Kind: type

Page: https://salmonui.dev/docs/reference/inputs/color-picker/ColorPickerMode

```ts
type ColorPickerMode = 'area' | 'swatches';
```

`'area'` (saturation and brightness area, sliders, hex field) or `'swatches'` (palette).

### ColorSwatchItem

Kind: type

Page: https://salmonui.dev/docs/reference/inputs/color-picker/ColorSwatchItem

```ts
type ColorSwatchItem = string | {
    readonly value: string;
    readonly label?: string | undefined;
};
```

A palette entry: a color string, or a color with its accessible name.
