Tac UIv1.1.2

ColorPicker

A color selector with spectrum gradient picker, swatch grid, eyedropper, and channel inputs for precise color selection. Includes a confirm button for two-step picking.

Import

tsx
import { ColorPicker } from '@tac-ui/web';

Default

The base picker renders a trigger button showing the selected color swatch. Opening the dropdown reveals the full spectrum picker, preset swatches, hex input, and channel inputs.

tsx
<ColorPicker placeholder="Select color" />

With Label

Use <code>label</code> to render an associated label above the trigger and <code>helperText</code> to display a hint below when there is no active error.

Choose a background color for the card.
tsx
<ColorPicker label="Background Color" helperText="Choose a background color for the card." />

Custom Colors

Pass a <code>colors</code> array of hex strings to replace the 30-color default preset grid with a custom palette. The grid always uses 6 columns.

tsx
<ColorPicker
  label="Grayscale"
  colors={['#0F172A', '#1E293B', '#334155', '#475569', '#64748B', '#94A3B8', '#CBD5E1', '#E2E8F0', '#F1F5F9', '#F8FAFC', '#FFFFFF', '#000000']}
/>

Without Spectrum

Set <code>showSpectrum={false}</code> to hide the saturation/brightness canvas and hue slider, leaving only the swatch grid and hex input.

tsx
<ColorPicker label="Simple Mode" showSpectrum={false} />

Without Channels

Set <code>showChannels={false}</code> to hide the RGB and HSB numeric input rows for a more compact panel layout.

tsx
<ColorPicker label="No Channels" showChannels={false} />

Swatches Only

Combine <code>showSpectrum={false}</code>, <code>showChannels={false}</code>, and <code>showEyeDropper={false}</code> to create a minimal swatch-only picker panel.

tsx
<ColorPicker label="Swatches Only" showSpectrum={false} showChannels={false} showEyeDropper={false} />

Without Input

Set <code>showInput={false}</code> to hide the hex text input and eyedropper row below the presets.

tsx
<ColorPicker label="Quick Pick" showInput={false} showChannels={false} />

Error State

Set <code>error</code> to apply destructive border styling to the trigger and pass <code>errorMessage</code> to display a validation message below it.

Please select a color.
tsx
<ColorPicker label="Theme Color" error errorMessage="Please select a color." />

Disabled

When <code>disabled</code> is true the trigger is non-interactive and the picker panel will not open.

tsx
<ColorPicker placeholder="Disabled" disabled />

Controlled

Use <code>value</code> and <code>onChange</code> for controlled usage. The <code>onChange</code> callback fires only when the Select button is pressed, making color changes explicit.

Selected: #3B82F6
tsx
const [color, setColor] = useState('#3B82F6');
<ColorPicker label="Brand Color" value={color} onChange={setColor} />

API Reference

PropTypeDefaultDescription
valuestring-Controlled selected color as a hex string.
onChange(color: string) => void-Called when a color is confirmed via the Select button.
labelstring-Label text displayed above the trigger.
placeholderstring"Select color"Placeholder text when no color is selected.
helperTextstring-Helper text displayed below the trigger when there is no error.
colorsstring[]30 default colorsCustom array of hex color strings for the swatch grid.
showInputbooleantrueShows a text input for manual hex entry.
showSpectrumbooleantrueShows the spectrum gradient picker for detailed color selection.
showEyeDropperbooleantrueShows the eyedropper button (requires browser support).
showChannelsbooleantrueShows RGB/HSB channel inputs for precise values.
errorbooleanfalseApplies error styling when true.
errorMessagestring-Error message displayed when error is true.
idstring-ID attribute for the trigger button; auto-generated if omitted.
disabledbooleanfalseDisables the picker.