PeakUIPro

CellColorPicker

Colour picker styled as a settings cell

Usage

import {CellColorPicker} from "@peakui-pro/react";

Anatomy

The ValueDisplay and the Swatch read the picker's state with no consumer wiring.

import {CellColorPicker} from "@peakui-pro/react";

// Rendered as: the Trigger (a <button>), the Label leading, the hex value,
// the Swatch in the current colour, and the Popover's editor below the row's end.
export default () => (
  <CellColorPicker defaultValue="#3b82f6">
    <CellColorPicker.Trigger aria-label="Accent colour">
      <CellColorPicker.Label>Accent</CellColorPicker.Label>
      <CellColorPicker.ValueDisplay />
      <CellColorPicker.Swatch />
    </CellColorPicker.Trigger>
    <CellColorPicker.Popover>{/* the editor */}</CellColorPicker.Popover>
  </CellColorPicker>
);

Examples

Variants

variant restyles the row.

Controlled

With Presets

The popover is whatever editor you bring: here the core ColorSwatchPicker above a ColorArea, a hue ColorSlider and a hex ColorField. They read the picker's colour with no wiring.

Settings Group

The row's leading label names the picker; the cell fills the value column.

Disabled

isDisabled goes to the Trigger — React Aria's button owns the disabled state.

Customization

Tailwind CSS

<CellColorPicker className="w-full">
  <CellColorPicker.Trigger>…</CellColorPicker.Trigger>
</CellColorPicker>

Global CSS

@layer components {
  /* The row's surface; the secondary variant swaps tone for shadow. */
  .cell-color-picker__trigger {
    @apply rounded-lg;
  }
}

Styling Reference

PeakUI follows the BEM methodology, so variants and states are plain class names you can target.

CSS Classes

The CellColorPicker component uses these CSS classes (view source styles):

Base Classes

  • .cell-color-picker - The root; beside the core ColorPicker's own classes on its wrapper

Element Classes

  • .cell-color-picker__trigger - The visible cell row; a surface 36px high with the label leading
  • .cell-color-picker__trigger--default - The default trigger variant
  • .cell-color-picker__trigger--secondary - A quieter row: bg-default-soft with no surface shadow
  • .cell-color-picker__label - The leading label; takes the room the value and swatch leave and truncates
  • .cell-color-picker__value-display - The hex of the current colour, read from the picker's state
  • .cell-color-picker__swatch - The core ColorSwatch, sized to the row's 20px circle
  • .cell-color-picker__popover - The popover the editor opens in

Slots

  • [data-slot="color-picker"] - The root wrapper (the core's own slot; the cell's block sits beside its classes)
  • [data-slot="cell-color-picker-trigger"] - The row
  • [data-slot="cell-color-picker-label"] - The label
  • [data-slot="cell-color-picker-value-display"] - The value display
  • [data-slot="cell-color-picker-swatch"] - The swatch
  • [data-slot="cell-color-picker-popover"] - The popover

API Reference

CellColorPicker

PropTypeDefaultDescription
variant'default' | 'secondary''default'The cell's own variant axis; the core ColorPicker beneath it has none
childrenReactNode-The parts
classNamestring-Additional classes
...restComponentProps<typeof ColorPickerRoot>-The core ColorPicker root's props: value, defaultValue, onChange, aria-label and the rest of React Aria's ColorPicker attributes

CellColorPicker.Trigger

PropTypeDefaultDescription
childrenReactNode | ((values) => ReactNode)-The row's content — the Label, the ValueDisplay and the Swatch
classNamestring-Additional classes
renderDOMRenderFunction<'button', ButtonRenderProps>-Replaces the rendered <button> with your own element
...restComponentProps<typeof ColorPickerTrigger>-The core ColorPicker.Trigger's props, React Aria's Button attributes among them, isDisabled included

CellColorPicker.Label

PropTypeDefaultDescription
childrenReactNode-The label text
classNamestring-Additional classes
renderDOMRenderFunction<'span', undefined>-Replaces the rendered <span> with your own element
...restComponentProps<'span'>-Native <span> attributes

CellColorPicker.ValueDisplay

PropTypeDefaultDescription
childrenReactNode-Custom content; the current colour in hex renders without it
classNamestring-Additional classes
renderDOMRenderFunction<'span', undefined>-Replaces the rendered <span> with your own element
...restComponentProps<'span'>-Native <span> attributes

CellColorPicker.Swatch

PropTypeDefaultDescription
classNamestring-Additional classes
renderDOMRenderFunction<'div', ColorSwatchRenderProps>-Replaces the rendered <div> with your own element
...restComponentProps<typeof ColorSwatchRoot>-The core ColorSwatch's props, React Aria's ColorSwatch attributes among them

CellColorPicker.Popover

PropTypeDefaultDescription
childrenReactNode-The editor; compose the core ColorArea, ColorSlider, ColorSwatchPicker and ColorField
placementPlacement'bottom end'Where the editor lands; the core's own default is 'bottom left'
classNamestring-Additional classes
renderDOMRenderFunction<'div', PopoverRenderProps>-Replaces the rendered <div> with your own element
...restComponentProps<typeof ColorPickerPopover>-The core ColorPicker.Popover's props, React Aria's Popover attributes among them

On this page