Skip to content
WunderUI

Cell Color Picker

Free

A round colour swatch for a table cell. It opens a small palette and sets the colour of one row.

npx wunderui-cli add cell-color-picker

Playground

LabelColour
Billing
Design
Support

Installation

bash
npx wunderui-cli add cell-color-picker

Writes the source into your project with its dependencies and, on first use, the styles - see Installation.

Then import what you need:

tsx
import { CellColorPicker } from "@/components/wunderui/table-cells"

Then use it inside a table cell:

tsx
import { useState } from "react"
import { CellColorPicker } from "@/components/ui/cell-color-picker"
import { TableCell } from "@/components/ui/table"

export function LabelColourCell() {
  const [color, setColor] = useState("#12AFF0")

  return (
    <TableCell>
      <CellColorPicker value={color} onValueChange={setColor} />
    </TableCell>
  )
}

Expected result: You see a 24 px blue circle in the cell. Click it to open a popover with six colours, choose one and the circle takes that colour.

When to use

Use Cell Color Picker for

  • A colour column in a table, such as a label colour, a calendar colour or a chart series
  • A short fixed palette of six colours
  • Colours that are stored as hex strings

Use something else for

  • Color Picker for a free colour with hex, RGB or HSL entry and opacity
  • Badge for a status or category in a fixed set of tints that the person does not choose
  • Cell Select for a choice between named options instead of colours

Colour

The palette has six fixed colours. The swatch shows the current one and the popover marks the match, so picking another colour changes the cell.

LabelColour
Billing

Keyboard interactions

The swatch button and every colour in the popover are native buttons, so the browser handles focus and activation.

TaborShiftTab
Moves focus to the next or previous control in the table, row by row. Each swatch button is one Tab stop.
EnterorSpace
On the swatch button: opens the popover. Tab then moves into it, through the six colours.
EnterorSpace
On a colour: chooses it and calls with its hex value. The popover stays open, so you can try another colour.
Escape
Closes the popover and returns focus to the swatch button.

The popover has no arrow-key navigation. Each of the six swatches is its own Tab stop.

Behavior and motion

What the cell colour picker does itself, and what it leaves to the table around it.

Controlled
CellColorPicker keeps no state. You supply the value, a choice calls the change handler with the hex string, and nothing changes until you set the value.
The palette
The palette has six fixed colours: blue, purple, orange-red, yellow, green and pink. A value outside the set shows on the swatch button, but no popover colour is marked.
Accessible name
Without a label the button reads Colour, its hex value and Choose a colour. With a label like Billing colour it reads the label plus the hex, so mark the first row cell as a row header too.
Popover
The popover opens below the swatch and is not clipped by the table card. It stays open after a choice and closes with Escape or a click outside.
Active colour
The matching swatch is marked pressed and has a ring. A colour outside the palette marks none.
Figma states
The Figma Editable Cell set has View, Edit, Changed, Saving, Error and Disabled. CellColorPicker has no props for these states.
Motion
The popover fades and scales in, then leaves faster. A swatch grows by 10 % on hover.
Reduced motion
With reduced motion the popover opens without moving and the swatches no longer grow. Only the fade stays.

Anatomy

The figure marks one swatch in its table: the column header, the row header and the swatch button. The popover opens on demand, so it is described below the figure.

LabelColour
Billing
  • data-slot="table"

    The table the cell sits in. The first column holds the row names, the header row names the columns, and the picker lives in a table cell.

  • The header of the colour column. It says what the colour is for, such as Colour or Chart colour.

  • The first cell of the row, marked as the row header, which says which label, calendar or series the colour belongs to. Give the swatch the same name as its aria-label.

  • A round swatch button that opens a six-colour popover. Built for a table cell, it returns the chosen colour as a hex string, and you hold the value and write it back on change.

  • data-slot="popover-trigger"

    The 24 px round trigger filled with the current colour. Its name is the label plus the hex value, and it announces a dialog.

  • data-slot="popover-content"

    The popover with the six swatches in one row. Its name comes from the aria-label, Choose a colour by default, and it stays open after a choice.

  • One of the six colour buttons in the popover, named by its hex value. The active one has a ring and is marked pressed.

Best practices

  • Do

    Keep the value as a hex string and store it in the change handler. The trigger names itself with that value.

  • Do

    Pass an aria-label that names the row, such as Billing colour, so the swatch reads Billing colour plus its hex value. Mark the first cell of each row as a row header too.

  • Do

    Show the effect of the choice nearby, such as a legend bar or a preview, so nobody judges the colour from a 24 px circle alone.

  • Do

    Give the colour column a header that says what the colour is for, and centre the swatch in a narrow column.

  • Don’t

    Don't expect colours outside the six swatches. Another value still shows on the trigger, but no swatch is marked and people can only pick from the six.

  • Don’t

    Don't use it outside a table row, since it is 24 px wide and has no visible label. Use ColorPicker for a labelled field with hex entry and opacity.

  • Don’t

    Don't use colour as the only carrier of meaning. Pair it with the name of the label or series, as the row header does.

  • Don’t

    Don't expect the Figma Editable Cell states (Edit, Changed, Saving, Error, Disabled). It only has a value and a change handler.

API reference

CellColorPicker is a plain function component with three props. It sets the trigger, palette and popover itself and passes no other props through.

A round swatch button that opens a six-colour popover. Built for a table cell, it returns the chosen colour as a hex string, and you hold the value and write it back on change.

PropTypeDefaultDescription
value requiredstring—The current colour as a hex string, such as . It is a controlled value. A value outside the six swatches shows on the button but marks no swatch.
onValueChange required(value) => void—Called with the hex string of the swatch the person chose. The popover stays open afterwards.
aria-labelstring—The accessible name of the swatch button, such as . The button is then named ; the popover uses the label as its name. Without it the button is named .

Notes for AI

Give your coding assistant the Markdown reference instead of screenshots.

MCPget_component("cell-color-picker")
Installnpx wunderui-cli add cell-color-picker

The full library index for assistants is at /llms.txt.