HextaUI

Color picker (UI SDK): Alpha

A slider with channel="alpha" edits opacity. Its track and the swatch draw a checkerboard under the color, so a see-through color reads as see-through.

import {
  ColorPicker,
  ColorPickerArea,
  ColorPickerInput,
  ColorPickerSlider,
  ColorPickerSwatch,
} from "@/components/ui/ui-sdk-color-picker"

function UiSdkColorPickerAlpha() {
  return (
    <ColorPicker
      aria-label="Overlay color"
      space="hsl"
      defaultValue="hsl(262 83% 58% / 0.6)"
    >
      <ColorPickerArea />
      <ColorPickerSlider channel="hue" />
      <ColorPickerSlider channel="alpha" />
      <div className="flex items-center gap-2">
        <ColorPickerSwatch />
        <ColorPickerInput aria-label="HSL" />
      </div>
    </ColorPicker>
  )
}

export { UiSdkColorPickerAlpha }

This adds the example as components/examples/ui-sdk-color-picker/alpha.tsx, together with the Color picker component and the HextaUI theme tokens it needs.

pnpm dlx shadcn@latest add https://hextaui.com/r/ui-sdk-color-picker-alpha.json

To add only the component, follow the Color picker installation.

Props in this example

The Color picker props this example sets, from the API reference.

PropTypeDefault
defaultValue
string"black"
spaceWhich channels the parts edit.
"hsv" | "hsl" | "srgb" | "oklch""hsv"
PropTypeDefault
channelHue, or blue in sRGB, by default.
ColorChannel–

Every prop is in the Color picker API reference.

See them all, with keyboard support and accessibility notes, on the Color picker page.