View as Markdown

API reference: @salmonui/inputs/color-picker

ColorFieldcomponent

import { ColorField } from '@salmonui/inputs/color-picker';
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

ColorField props (19)
NameSignatureDescription
valueoptionalreadonly value?: ColorInput | null | undefined;
defaultValueoptionalreadonly defaultValue?: ColorInput | null | undefined;
onValueChangeoptionalreadonly onValueChange?: ((value: string | null, details: ColorFieldChangeDetails) => void) | undefined;

Called with the entry in valueFormat after it parses (blur or Enter), or null when emptied.

valueFormatoptionalreadonly valueFormat?: ColorFormat | undefined;

Format of the shown and reported value. Default 'hexa'.

clearableoptionalreadonly clearable?: boolean | undefined;
showSwatchoptionalreadonly showSwatch?: boolean | undefined;

A ColorSwatch of the value as the start adornment. Default true.

endAdornmentoptionalreadonly endAdornment?: ReactNode;
localeTextoptionalreadonly localeText?: (FieldValidationText & { readonly clear?: string; readonly colorName?: (color: Color) => string; }) | undefined;
classNameoptionalreadonly className?: string | undefined;
styleoptionalreadonly style?: CSSProperties | undefined;
classNamesoptionalreadonly classNames?: { readonly group?: string; readonly input?: string; readonly label?: string; readonly description?: string; readonly error?: string; } | undefined;
refoptionalreadonly ref?: Ref<HTMLInputElement> | undefined;

The native <input>.

labeloptionalinheritedlabel?: ReactNode;
descriptionoptionalinheriteddescription?: ReactNode;
errorMessageoptionalinheritederrorMessage?: ((ctx: { readonly errors: readonly string[]; }) => ReactNode) | ReactNode;

Error text (or a function of the errors) shown while the field is invalid.

invalidoptionalinheritedinvalid?: boolean;

Forces the error state.

validationoptionalinheritedvalidation?: FieldValidation;

Rules in the Data Grid vocabulary.

validateOnoptionalinheritedvalidateOn?: ValidateOn;

When errors appear; default the Form's, else 'blur'.

sizeoptionalinheritedsize?: FieldSize;

Metric set. Default 'md'.