Form Color Select

GitHub

Color select connected to Form context with server validation errors.

Installation

bash
pnpm dlx shadcn@latest add @cs/form-color-select

Usage

tsx
import { FormColorSelect } from "@/components/cs/form-color-select"
tsx
<FormColorSelect name="color" />

API Reference

FormColorSelect

Color select connected to Form context with server validation errors.

Props

NameTypeDefaultDescription
colorTarget *ColorTarget-Tailwind color utility prefix used for the selected value, or raw-color for direct CSS color values.
defaultValuestring | null | undefined-Initial selected value for uncontrolled usage.
labelstring | undefined-Visible field label.
name *string-Form field name used for submission and validation errors.
onValueChange((value: string | null) => void) | undefined-Called when the selected value changes.
optionsLegacySelectOption[] | undefined-Color options displayed in the menu. With a Tailwind utility colorTarget, custom option values must use bg-* classes, such as bg-red-200 dark:bg-red-700; the bg- prefix is replaced with colorTarget for the selected value. With colorTarget="raw-color", values must be direct CSS colors, such as hex values like #16a34a, and are returned unchanged. The supplied color value is displayed as the swatch in both modes.
orientation"vertical" | "horizontal" | "responsive" | null | undefined--
placeholderstring | undefined-Text displayed when no option is selected.
requiredboolean | undefined-Requires a selected value before the form can submit.
selectClassNamestring | undefined-Additional classes applied to the select trigger.
valuestring | (readonly string[] & string) | undefined-Controlled selected value.