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
| Name | Signature | Description |
|---|---|---|
valueoptional | readonly value?: ColorInput | null | undefined; | |
defaultValueoptional | readonly defaultValue?: ColorInput | null | undefined; | |
onValueChangeoptional | readonly onValueChange?: ((value: string | null, details: ColorFieldChangeDetails) => void) | undefined; | Called with the entry in |
valueFormatoptional | readonly valueFormat?: ColorFormat | undefined; | Format of the shown and reported value. Default |
clearableoptional | readonly clearable?: boolean | undefined; | |
showSwatchoptional | readonly showSwatch?: boolean | undefined; | A |
endAdornmentoptional | readonly endAdornment?: ReactNode; | |
localeTextoptional | readonly localeText?: (FieldValidationText & {
readonly clear?: string;
readonly colorName?: (color: Color) => string;
}) | undefined; | |
classNameoptional | readonly className?: string | undefined; | |
styleoptional | readonly style?: CSSProperties | undefined; | |
classNamesoptional | readonly classNames?: {
readonly group?: string;
readonly input?: string;
readonly label?: string;
readonly description?: string;
readonly error?: string;
} | undefined; | |
refoptional | readonly ref?: Ref<HTMLInputElement> | undefined; | The native |
labeloptionalinherited | label?: ReactNode; | |
descriptionoptionalinherited | description?: ReactNode; | |
errorMessageoptionalinherited | errorMessage?: ((ctx: { readonly errors: readonly string[]; }) => ReactNode) | ReactNode; | Error text (or a function of the errors) shown while the field is invalid. |
invalidoptionalinherited | invalid?: boolean; | Forces the error state. |
validationoptionalinherited | validation?: FieldValidation; | Rules in the Data Grid vocabulary. |
validateOnoptionalinherited | validateOn?: ValidateOn; | When errors appear; default the |
sizeoptionalinherited | size?: FieldSize; | Metric set. Default |