GitHub
Core
Glass
Brutal
Humanist

Color Picker
Pro

Allows users to select, preview, and edit colors using visual controls and numeric color values.

Color Picker Playground

Color Picker Playground
Preview
Code
#
%

Recently Used

Controls
Format:
HEX
RGB
HSL
HSB
Opacity Slider:
Color Swatches:
EyeDropper Sampler:
Copy Button:
Disabled:

Installation

You can add the color picker component to your project manually:

1

Install the following dependencies:

npm install class-variance-authority clsx tailwind-merge @phosphor-icons/react
2

Copy and paste the following code into your project.

Loading...
3

Update the import paths to match your project setup.

Update the import aliases (e.g. @/components, @/utils) in the copied files to match your project's path configuration.

Basic Usage

import { useState } from 'react';
import { ColorPicker } from '@versaui/ui/components/ColorPicker';

function Example() {
  const [color, setColor] = useState('#9423D9');

  return (
    <ColorPicker
      value={color}
      onValueChange={setColor}
      format="Hex"
      opacitySlider={true}
    />
  );
}

Subcomponents Usage

Standalone Color Input

import { useState } from 'react';
import { ColorInput } from '@versaui/ui/components/ColorPicker';

function InputExample() {
  const [hex, setHex] = useState('9423D9');

  return (
    <ColorInput
      mode="Hex"
      hexValue={hex}
      onHexChange={setHex}
      colorString={`#${hex}`}
      colorPreview={true}
      copyColor={true}
      size="Default"
    />
  );
}

Color Sliders (Hue & Opacity)

import { useState } from 'react';
import { ColorSlider } from '@versaui/ui/components/ColorPicker';

function SlidersExample() {
  const [hue, setHue] = useState(277);
  const [opacity, setOpacity] = useState(0.85);

  return (
    <div className="space-y-4">
      <ColorSlider type="Hue" value={hue} onChange={setHue} />
      <ColorSlider type="Opacity" value={opacity} color="rgb(148, 35, 217)" onChange={setOpacity} />
    </div>
  );
}

Color Swatches & Swatch Group

import { ColorSwatch, ColorSwatchGroup } from '@versaui/ui/components/ColorPicker';

function SwatchesExample() {
  return (
    <ColorSwatchGroup
      title="Presets"
      selectedColor="#615FFF"
      onSelectColor={(color) => console.log(color)}
    />
  );
}

Accessibility

  • Built using WAI-ARIA Slider specification (role="slider", aria-valuenow, aria-valuemin, aria-valuemax).
  • Full keyboard support for ColorArea (Arrow keys for 1% shifts, Shift + Arrow keys for 10% shifts) and ColorSlider (Arrow keys, Shift + Arrow keys for 10% steps, Home / End for bounds).
  • Token-based focus ring (--focus-ring-primary) on interactive spectrum and sliders with 4px handle stroke when focused.
  • Accessible button semantics for ColorSwatch, ColorSampler, and CopyColor.

Component Props

ColorPicker Props

PropTypeDefaultDescription
valuestringundefinedControlled hex or rgba color string.
defaultValuestring'#9423D9'Default color string for uncontrolled mode.
onValueChange(color: string) => voidundefinedCallback fired on color change.
format'Hex' | 'RGB' | 'HSL' | 'HSB''Hex'Active color input format.
onFormatChange(format: 'Hex' | 'RGB' | 'HSL' | 'HSB') => voidundefinedCallback fired on format change.
colorPreviewbooleantrueRenders the preview color swatch in the color input bar.
opacitySliderbooleantrueRenders the opacity slider.
colorGroupbooleantrueRenders preset/recently used swatches.
colorSamplerbooleantrueRenders the EyeDropper sampling button.
copyColorbooleantrueRenders the copy color action button.
presetColorsstring[]undefinedCustom array of preset color strings.
disabledbooleanfalseDisables all color picker controls.

ColorInput Props

PropTypeDefaultDescription
mode'Hex' | 'RGB' | 'HSL' | 'HSB''Hex'Input color mode.
size'Default' | 'Small''Default'Height and border radius size variant.
colorPreviewbooleantrueEmbedded left color preview swatch.
opacityInputbooleantrueEmbedded opacity percentage input.
copyColorbooleantrueEmbedded right copy action button.
hexValuestring'9423D9'Controlled 6-digit hex string.
colorStringstring'rgba(148, 35, 217, 0.84)'Full formatted color string for preview swatch and copy action.
opacityValuenumber84Opacity percentage value (0 - 100).
onHexChange(hex: string) => voidundefinedCallback fired on valid hex input change.
onOpacityChange(opacityPct: number) => voidundefinedCallback fired on opacity percentage change.
onCopyColor(formattedColor: string) => voidundefinedCallback fired on color copy action.
disabledbooleanfalseDisables input interaction.

On this page