Chroma Panel

Search documentation

Find a page or section

ChromaPanel

Reach for it when you are placing the picker in a sidebar, a modal you control, or a page of your own.

Anatomy

import { ChromaPanel } from "chroma-panel";
 
<ChromaPanel defaultValue="#3366cc" modes={["wheel"]} showTitleBar={false} />;

Demo

Loading…
chroma-panel-demo.tsx
"use client";
 
import { ChromaPanel } from "chroma-panel";
 
export default function ChromaPanelDemo() {
  return <ChromaPanel defaultValue="#3366cc" injectStyles={false} />;
}

API reference

Props

PropTypeDefaultDescription
valuestring | HsvaThe colour, when you keep it in your own state.
defaultValuestring | Hsva'#3366cc'The starting colour, when you want the panel to keep it.
onChange(color: ColorChangeResult) => voidFires continuously while a drag is in progress.
onChangeComplete(color: ColorChangeResult) => voidFires once when the drag ends. Use it for saving, undo entries and network calls.
modes(ModeId | string | PickerMode)[]all fiveWhich tabs appear, in the order you list them.
modestringThe open tab, when you control it.
defaultModestringfirst modeThe tab to open on.
onModeChange(mode: string) => voidFires when the reader switches tabs.
formatColorFormat'hex'Sets the css string on the change result, and the value a form submits.
showAlphabooleantrueTurn off when opacity is not allowed.
showEyedropperbooleantrueTurn off to hide the eyedropper even where it is supported.
showRecentColorsbooleantrueTurn off in a one-shot picker.
recentColorsstring[]The recent-colour history, when you keep it. Persist it yourself to carry the list between sessions.
defaultRecentColorsstring[][]The starting history, when you want the panel to keep it.
onRecentColorsChange(colors: string[]) => voidFires with the whole list whenever a colour is added to it.
palettesColorPalette[]built-in setReplaces the palette swatches with your own.
pencilsstring[]built-in 120-colour gridReplaces the pencil grid.
modePropsRecord<string, Record<string, unknown>>Props spread onto one mode's panel, keyed by mode id. Lets a custom mode take props without the panel knowing about it.
imageOptionsExtractOptionsShorthand for modeProps.image.extractOptions.
disabledbooleanfalseMakes the panel read-only.
theme"dark" | "light"systemForces one theme instead of following the OS.
showTitleBarbooleantrueTurn off for an inline panel with no chrome.
titlestring'Colours'The title bar text.
onClose() => voidFires when the red window control is used. An inline panel has nothing to close, so that control is dimmed until you pass this.
collapsedbooleanWhether the panel is collapsed to its title bar, when you control it.
defaultCollapsedbooleanfalseWhether it starts collapsed. Collapsing hides the body with CSS rather than unmounting, so nothing is lost.
onCollapsedChange(collapsed: boolean) => voidFires when the yellow window control is used.
sizePanelSizeThe panel size, when you control it.
defaultSizePanelSize'default'The starting size. 'expanded' widens the panel, and the wheel with it.
onSizeChange(size: PanelSize) => voidFires when the green window control is used.
injectStylesbooleantrueTurn off when you import chroma-panel/style.css yourself, as this site does.
classNamestringClass applied to the panel root.
classNamesChromaClassNamesClasses applied per part.
styleReact.CSSPropertiesInline styles on the panel root. Setting the --cp-* custom properties here themes a single panel.
storeColorStoreAn external colour store, for driving several panels from one colour.