#2f7ed8
Installation
$ pnpm dlx shadcn@latest add @synccn/color-pickerFirst time in this project? Connect synccn with one command.
Usage
import { ColorPicker } from "@/components/ui/color-picker";<ColorPicker value={hex} onValueChange={setHex} />API reference
Generated from the component's TypeScript types, so it always matches the code.
PropTypeDescription
- value
stringControlled hex colour.
- defaultValue
stringDefault
"#2f7ed8"Initial hex colour when uncontrolled.
- onValueChange
(hex: string) => voidCalled with the new hex colour.
- swatches
string[]Default
SWATCHESPreset colours shown under the picker.
- className
stringExtra classes for the root element.
Dependencies
Read from the component's imports when the site builds. The CLI installs all of these for you.
npm packages
- clsx for cn()
- tailwind-merge for cn()
Accessibility
- The saturation area and hue bar are sliders; the hex field accepts typed values for precise input.
From the source
Read from this component's code when the site builds, so it can't drift.
- ARIA roles: slider
- ARIA attributes: aria-label, aria-valuemax, aria-valuemin, aria-valuenow, aria-valuetext
- Keys handled: ArrowUp, ArrowDown, ArrowLeft, ArrowRight
More inputs
ButtonSeven variants, four sizes and a built-in loading state.InputText field with optional leading icon and invalid state.TextareaMulti-line field that grows with its content and counts characters.CheckboxChecked, unchecked and indeterminate, with label and description.SwitchToggle with a springy thumb in three sizes.Radio GroupPick one option, shown as dots or as selectable cards.