Skip to content

Color Picker

InputMIT
View in Storybook

Inline color picker with HEX / RGB / HSL formats, optional alpha + swatches, and native eye-dropper.

bun add @otfdashkit/ui

Preview

Color Picker
Loading Storybook preview…

Code

import { useState } from 'react'
import { ColorPicker } from '@otfdashkit/ui'

export function Example() {
  const [value, setValue] = useState('#3b82f6')
  return (
    <div className="flex flex-col gap-3">
      <ColorPicker value={value} onValueChange={setValue} />
      <p className="font-mono text-xs text-muted-foreground">value: {value}</p>
    </div>
  )
}

Free with the SDK. This component ships in @otfdashkit/ui under the MIT license.

Props

Props declared in the ColorPicker source. Inherited HTML attributes are not listed.

PropTypeDefaultDescription
defaultValuestring | (readonly string[] & string)Uncontrolled initial value.
disabledbooleanfalseDisable interaction.
format'hex' | 'rgb' | 'hsl''hex'Format for the text input + picker. Default 'hex'.
onValueChange(value: string) => voidFires whenever the color changes.
showAlphabooleanfalseInclude alpha channel (only meaningful for hex). Default false.
showEyeDropperbooleantrueShow the eye-dropper button when the API is available. Default true.
swatchesstring[]Optional preset palette displayed as clickable swatches.
valuestringControlled color value (e.g. '#3b82f6' for hex, 'rgb(59, 130, 246)' for rgb).