ColorInput

Color picker input backed by the native <input type="color"> element. Stores a hex color string. Supports optional preset swatches.

Installation

pnpm dlx shadcn@latest add @shadmin/color-input

Usage

import { ColorInput } from '@/components/admin';
 
<ColorInput source="color" />
<ColorInput source="color" swatches={["#ef4444", "#3b82f6", "#10b981"]} />
<ColorInput source="color" disabled />

Props

PropRequiredTypeDefaultDescription
sourceRequiredstring-Form field name
swatchesOptionalreadonly string[]-Preset hex strings rendered as buttons
labelOptionalstring | falseInferredCustom label, or false to hide
helperTextOptionalReactNode-Helper text below the input
disabledOptionalbooleanfalseDisable input + swatches
defaultValueOptionalstring-Initial color value
validateOptionalValidator | Validator[]-Validation
classNameOptionalstring-CSS class on the wrapping <FormField>

Storage format

The native <input type="color"> element only emits 6-digit lowercase hex (e.g. #3b82f6).