View as Markdown

API reference: @salmonui/inputs/color-picker

ColorSwatchPickerPropsinterface

import type { ColorSwatchPickerProps } from '@salmonui/inputs/color-picker';
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;
}
ColorSwatchPickerProps members (17)
NameSignatureDescription
colorsoptionalreadonly colors?: readonly ColorSwatchItem[] | readonly ColorSwatchGroup[] | undefined;

Flat entries or labelled groups. Default: a 10-column palette of grays and 9 hues in 5 shades.

columnsoptionalreadonly columns?: number | undefined;

Swatches per row. Default 10.

valueoptionalreadonly value?: string | null | undefined;
defaultValueoptionalreadonly defaultValue?: string | null | undefined;
onValueChangeoptionalreadonly onValueChange?: ((value: string | null, details: SwatchChangeDetails) => void) | undefined;
clearableoptionalreadonly clearable?: boolean | undefined;

Adds a "no color" swatch first; picking it sets null.

renderSwatchoptionalreadonly renderSwatch?: ((ctx: SwatchRenderContext) => ReactNode) | undefined;

Replaces the swatch inside each option.

nameoptionalreadonly name?: string | undefined;

Name of a hidden input carrying the value ('' for no color).

formoptionalreadonly form?: string | undefined;
disabledoptionalreadonly disabled?: boolean | undefined;
localeTextoptionalreadonly localeText?: { readonly noColor?: string; readonly colorName?: (color: Color) => string; } | undefined;
classNameoptionalreadonly className?: string | undefined;
styleoptionalreadonly style?: CSSProperties | undefined;
idoptionalreadonly id?: string | undefined;
aria-labeloptionalreadonly 'aria-label'?: string | undefined;
aria-labelledbyoptionalreadonly 'aria-labelledby'?: string | undefined;
refoptionalreadonly ref?: Ref<HTMLDivElement> | undefined;

The listbox element.