Chroma Panel

Search documentation

Find a page or section

One colour, as a button with an accessible name.

Anatomy

import { Swatch } from "chroma-panel";

Only inside a panel

This is one of the parts the built-in modes are made of. It reads the colour through usePanel(), so it only works inside a ChromaPanel — typically in a custom mode. For a picker outside the panel, use the store and hooks.

API reference

Props

PropTypeDefaultDescription
color*stringThe colour it shows and reports. Any CSS colour string.
labelstringthe colour stringAccessible name. Give named swatches a real name rather than a hex value.
matchKeystringthe colour stringThe value compared against the current colour to decide the selected ring. Set it when the displayed colour is not what selection should match on.
roundbooleanfalseRender as a circle instead of a rounded square.
disabledbooleanfalseMakes the swatch unselectable.
onSelect(color: string) => voidFires with the colour when chosen.
classNamestringClass on the swatch.