Skip to content
Haze UI

Color Picker

A native color field with named preset swatches and a readable color value.

pnpm dlx shadcn@latest add @haze/color-picker
Open preview in a new tab
Livesmall script

When to use

  • A form collects an accent or label color.
  • A preset palette helps users choose quickly while still allowing custom colors.

When not to use

  • The application needs color profiles or transparency editing.

Installation

Add the Haze registry to components.json once, then install Color Picker with the shadcn CLI. Works in any Astro project with Tailwind CSS v4.

pnpm dlx shadcn@latest add @haze/color-picker
First time? Registry and theme setup

1. Add to components.json:

{
  "registries": {
    "@haze": "http://localhost:4329/r/{name}.json"
  }
}

2. Install the theme once: npx shadcn@latest add @haze/theme, then import it after Tailwind in your global CSS:@import "./haze.css";

API reference

PropTypeDefaultDescription
id*string–Unique color field ID.
namestringidSubmitted field name.
labelstringColorVisible and accessible label.
valuestring–Initial hexadecimal sRGB color.
swatchesSwatch[]–Named opaque CSS colors or custom properties.
disabledboolean–Disables the picker and its presets.
classstring–Classes for the field wrapper.

Keyboard interactions

Tab
Move to the native picker and preset colors.
EnterSpace
Choose a preset or open the native color picker.

Accessibility

  • Presets expose accessible names and a pressed state.
  • The selected color value and the native picker are available without relying on swatch color alone.

Notes for AI

Copy into Claude Code, Cursor, Codex or any coding agent. Agents can also read the Markdown version of this page.

  • Install and use

    Install the Haze UI component "Color Picker" with `npx shadcn@latest add @haze/color-picker`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "http://localhost:4329/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import ColorPicker from "@/components/haze/ui/color-picker.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: http://localhost:4329/ui/color-picker.md

  • Customize with real content

    Adapt the Haze color-picker ui for our product. Replace the demo values of these props with our real content: id, name, label, value, swatches, disabled, class. Keep the layout, the heading level rules and these accessibility details: Presets expose accessible names and a pressed state. The selected color value and the native picker are available without relying on swatch color alone. Do not add raw color classes; use the Haze tokens.

  • Choose the right block

    Before using color-picker, check it fits: use it when a form collects an accent or label color.; a preset palette helps users choose quickly while still allowing custom colors.. Avoid it when the application needs color profiles or transparency editing.. Alternatives: @haze/radio-group, @haze/chip, @haze/input.

Dependencies

  • npm: @lucide/astro
  • @haze/utils
  • @haze/theme (one-time setup)

Source · Original Haze UI work.

Catalog

↑↓ moveEnter openEsc close

Keyboard shortcuts

CtrlK
Command palette
/
Focus search
←↑→↓
Move between cards
jk
Next / previous card
ci
Copy code / install command (detail page)
[]
Previous / next entry
?
This help
Esc
Close dialog