Skip to content
Logic2BUI

Search docs

Search components and documentation

New
Menu

Color Picker

A self-contained HSV color picker with a saturation/value area, hue slider and hex input.

#3b82f6

Installation

npx logic2b@next add color-picker

Usage

import { ColorPicker } from "@/components/ui/color-picker"

const [color, setColor] = React.useState("#3b82f6")

<ColorPicker value={color} onValueChange={setColor} />

Drag inside the square to set saturation and brightness, drag the hue bar to set the hue, or type a hex value directly. It emits a #rrggbb string and is fully pointer-driven with zero dependencies.

Live playground

Edit the component props and inspect the exact JSX before copying it. The preview loads only when this section enters the viewport.

Generated JSX
<ColorPicker
  defaultValue="#2563eb"
  aria-label="Brand color"
 />

API reference

Generated from the public TypeScript exports in src/ui/color-picker.tsx.

View JSON

ColorPickerProps

Type
interface ColorPickerProps extends Omit<React.ComponentProps<"div">, "onChange" | "defaultValue"> { /** Current color as a `#rrggbb` hex string (controlled). */ value?: string defaultValue?: string onValueChange?: (hex: string) => void }

ColorPicker

Component

A self-contained HSV color picker: a saturation/value area, a hue slider and a hex input. Controlled via `value`/`onValueChange` or uncontrolled via `defaultValue`. Emits `#rrggbb`. Zero dependencies.

Props: ColorPickerProps
PropTypeRequiredDefaultDescription
valuestringNo—Current color as a `#rrggbb` hex string (controlled).
defaultValuestringNo——
onValueChange(hex: string) => voidNo——

Accessibility contract

Machine-readable behavior and consumer responsibilities for color-picker.

View JSON
Support
Authored behavior
Pattern
color input

Built-in semantics

  • The hexadecimal text input has an accessible name and provides a keyboard-editable fallback.

Consumer responsibilities

  • Add a visible label and communicate validation for invalid hex values.

Known limitations

  • • The saturation/value area and hue rail are pointer-only; keyboard users must edit the hex field.