# Color picker

A controlled native color and hex field pair with presets, validation, read-only and disabled states, and native form reset support.

Access: pro. Category: Forms. Kind: primitive.

## When to use

- Use it when a product interface needs a controlled native color and hex field pair with presets, validation, read-only and disabled states, and native form reset support.
- Choose it when the host application can supply the required state and keep business logic outside the presentation component.

## Alternatives

- Choose form-field instead when a labeled email field with validation and help text is the actual interface need, rather than color picker.

## Setup for agents

Use React 19 and TypeScript. Initialize shadcn for your framework, then merge this exact entry into components.json:

```json
{
  "registries": {
    "@tidal-pro": {
      "url": "https://tidalui.com/r/pro/{name}.json",
      "headers": {
        "Authorization": "Bearer ${TIDALUI_TOKEN}"
      }
    }
  }
}
```

The namespace must be named **@tidal-pro** because transitive Pro dependencies use that namespace. Obtain an agent key from your active Pro account at https://tidalui.com/account. Keep TIDALUI_TOKEN in your local environment, never in components.json, client code, Git or logs.

```sh
export TIDALUI_TOKEN='your-private-agent-key'
npx shadcn@latest add @tidal-pro/waitlist-form
npx shadcn@latest add https://tidalui.com/r/tidal-button.json
```

Free command: `npx shadcn@latest add https://tidalui.com/r/<name>.json`.
Pro command: `npx shadcn@latest add @tidal-pro/<name>`.

Import the base stylesheet and every stylesheet listed on the installed item's metadata. For example:

```tsx
import "./components/ui/tidal.css";
import "./components/ui/hero-section.css";
// Place installed components inside this wrapper:
<div className="tidal-scope" data-theme="dark">...</div>
```

Omit data-theme for the default light theme. Put the attribute on the same tidal-scope element for dark mode. Every component installs the shared free tidal-base dependency. After upgrading, run `npx shadcn@latest add https://tidalui.com/r/tidal-base.json --overwrite` to receive current tokens. Review local modifications before overwriting.

Vite: Use React + TypeScript. Map @/* to ./src/* in paths and Vite resolve.alias. Import tidal.css and each component stylesheet in your application entry.

Next.js 15 App Router: Next.js App Router: import tidal.css and component CSS in app/layout.tsx. Interactive examples belong in a client component with "use client". Map @/* to ./* or ./src/* to match your project.

TypeScript 6: use paths without baseUrl:

```json
{
  "compilerOptions": {
    "paths": {
      "@/*": [
        "./src/*"
      ]
    }
  }
}
```

Pro registry requests are server/CLI-only. Use the same-origin account interface in a browser; cross-origin Authorization preflights are intentionally unsupported.


## Install Color picker

```sh
npx shadcn@latest add @tidal-pro/color-picker
```

Stylesheets: `components/ui/tidal.css`, `components/ui/color-picker.css`.

## Minimal example

```tsx
import"./components/ui/tidal.css";
import"./components/ui/color-picker.css";
import{TidalColorPicker}from"./components/ui/color-picker";
export default()=><div className="tidal-scope"><TidalColorPicker onValueChange={() => {}} presets={[{id:"example",value:"value",label:"Demo",accessibleLabel:"Demo"}]} title={"Demo"} value={"value"}/></div>;
```

## Structured props

- `TidalColorPicker.onValueChange: (value: string, source: TidalColorPickerChangeSource, event: TidalColorPickerChangeEvent) => void`: Callback invoked when the value change interaction is proposed.
- `TidalColorPicker.presets: ReadonlyArray<TidalColorPreset>`: Required presets value accepted by this exported component.
- `TidalColorPicker.title: ReactNode`: Required title value accepted by this exported component.
- `TidalColorPicker.value: string`: Required value value accepted by this exported component.
- `TidalColorPicker.colorInputProps?: Omit<InputHTMLAttributes<HTMLInputElement>, "disabled" | "type" | "value" | "defaultValue" | "aria-disabled" | "aria-readonly" | "children" | "readOnly"> | undefined`: Optional color input props value accepted by this exported component.
- `TidalColorPicker.colorInputRef?: Ref<HTMLInputElement> | undefined`: Optional color input ref value accepted by this exported component.
- `TidalColorPicker.description?: ReactNode`: Optional description value accepted by this exported component.
- `TidalColorPicker.disabled?: boolean | undefined` (default false): Optional disabled value accepted by this exported component.
- `TidalColorPicker.eyebrow?: ReactNode`: Optional eyebrow value accepted by this exported component.
- `TidalColorPicker.footer?: ReactNode`: Optional footer value accepted by this exported component.
- `TidalColorPicker.headingLevel?: "h2" | "h3" | "h4" | undefined` (default "h2"): Optional heading level value accepted by this exported component.
- `TidalColorPicker.hexInputProps?: Omit<InputHTMLAttributes<HTMLInputElement>, "disabled" | "type" | "value" | "defaultValue" | "spellCheck" | "aria-disabled" | "aria-readonly" | "children" | "maxLength" | "pattern" | "placeholder" | "readOnly" | "required"> | undefined`: Optional hex input props value accepted by this exported component.
- `TidalColorPicker.hexInputRef?: Ref<HTMLInputElement> | undefined`: Optional hex input ref value accepted by this exported component.
- `TidalColorPicker.hint?: ReactNode`: Optional hint value accepted by this exported component.
- `TidalColorPicker.labels?: Partial<TidalColorPickerLabels> | undefined`: Optional labels value accepted by this exported component.
- `TidalColorPicker.readOnly?: boolean | undefined` (default false): Optional read only value accepted by this exported component.
- `TidalColorPicker.required?: boolean | undefined` (default false): Optional required value accepted by this exported component.
- `TidalColorPicker.resetAction?: TidalColorPickerResetAction | undefined`: Optional reset action value accepted by this exported component.
- `TidalColorPicker.validationMessage?: ReactNode`: Optional validation message value accepted by this exported component.

## Complete usage example

[Source](https://tidalui.com/examples/color-picker.tsx) | [Manifest](https://tidalui.com/examples/color-picker.json). Install the listed additional dependencies. Consumer fixture: TypeScript pass; Vite pass. This fixture check is distinct from the actual shadcn install receipt.

```tsx
"use client";

import "./components/ui/tidal.css";

import { useId, useState } from "react";

import { TidalColorPicker } from "./components/ui/color-picker";

import "./components/ui/color-picker.css";



const tidalExampleStyles = ".tidal-scope .color-picker-demo,\n.tidal-scope .color-picker-demo * {\n  box-sizing: border-box;\n}\n\n.tidal-scope .color-picker-demo {\n  width: 100%;\n  min-width: 0;\n  container: color-picker-demo / inline-size;\n}\n\n.tidal-scope .color-picker-demo-frame {\n  min-width: 0;\n  padding: 20px;\n  border: 1px solid var(--t-border);\n  border-radius: 22px;\n  background: var(--t-subtle);\n}\n\n.tidal-scope .color-picker-demo-frame form {\n  min-width: 0;\n  margin: 0;\n}\n\n@container color-picker-demo (max-width: 520px) {\n  .tidal-scope .color-picker-demo-frame {\n    padding: 8px;\n  }\n}";

const PRESETS = [
  { id: "ink", value: "#171717", label: "Ink" },
  { id: "graphite", value: "#525252", label: "Graphite" },
  { id: "silver", value: "#a3a3a3", label: "Silver" },
  { id: "white", value: "#ffffff", label: "White" },
] as const;

export function ColorPickerDemo() {
  const generatedId = useId().replace(/:/g, "");
  const formId = `color-picker-${generatedId}-form`;
  const [value, setValue] = useState("#171717");
  const [message, setMessage] = useState("Ink selected.");

  return (
    <section className="color-picker-demo" aria-label="Color picker preview">
      <div className="color-picker-demo-frame">
        <form
          id={formId}
          onSubmit={(event) => event.preventDefault()}
          onReset={() => {
            setValue("#171717");
            setMessage("Color reset to Ink.");
          }}
        >
          <TidalColorPicker
            title="Color picker"
            description="Choose a preset or enter a hex color."
            value={value}
            onValueChange={(nextValue, source) => {
              setValue(nextValue);
              setMessage(
                source === "preset"
                  ? "Preset selected."
                  : source === "color"
                    ? "Color updated."
                    : "Hex color updated.",
              );
            }}
            presets={PRESETS.map((preset) => ({
              ...preset,
              accessibleLabel: `Use ${preset.label}, ${preset.value}`,
            }))}
            required
            hint="Use six hexadecimal digits, such as #171717."
            colorInputProps={{ name: "sampleColor", form: formId }}
            hexInputProps={{ name: "sampleHex", form: formId }}
            resetAction={{
              label: "Reset color",
              accessibleLabel: "Reset color to Ink",
              buttonProps: { form: formId },
            }}
            footer={
              <span role="status" aria-live="polite">
                {message} Sample data. Changes stay in this preview.
              </span>
            }
          />
        </form>
      </div>
    </section>
  );
}

export default function AgentExample() {
  return (
    <div className="tidal-scope" data-theme="light" dir="ltr">
      <style>{tidalExampleStyles}</style>
      <ColorPickerDemo />
    </div>
  );
}

```

## Gotchas

- The host application owns data, validation, persistence, navigation, and service side effects described by this API.

## Theme and accessibility

{"tokens":["--t-accent","--t-border","--t-border-strong","--t-canvas","--t-danger","--t-display","--t-ease-out","--t-ease-spring","--t-faint","--t-font","--t-ink","--t-line","--t-muted","--t-primary","--t-primary-contrast","--t-radius-card","--t-radius-control","--t-radius-overlay","--t-radius-panel","--t-ring","--t-shadow-lg","--t-shadow-soft","--t-soft","--t-subtle","--t-surface","--t-wash"],"darkMode":true}

{"keyboard":["Tab and Shift+Tab follow the component's native focus order.","Arrow-key behavior follows the exported composite-control implementation."],"aria":"The component wires labels and relationships from consumer-provided visible text or ARIA props; preserve those labels in production.","notes":"Verify focus visibility, text alternatives, contrast, and reduced motion in the final composition."}

title, consumer-controlled six-digit hex value, onValueChange and typed presets are required. The component renders a labelled native color input plus a controlled text field with six-digit hex pattern, visible value, built-in syntax validation and optional consumer validation message. Native input attributes/form ownership and refs pass through while conflicting controlled/default/type/pattern props are excluded. Disabled blocks both fields, presets and reset; readOnly keeps the hex field readable while disabling mutation controls. Presets are native pressed buttons with visible/accessibility labels, native attributes/refs and native-handler-first prevented composition; invalid supplied preset values resolve disabled. Optional resetAction is a native type=reset button with form ownership, attributes/ref and an unprevented higher callback. Optional labels, hint, heading level, footer and native section attributes/ref remain consumer-owned. Dynamic preview and preset colors come only from supplied values through scoped CSS custom properties; component chrome remains neutral. The component performs no clipboard, network, request, analytics, storage or persistence action.
