Skip to content

Color Picker

Free

A color pick that opens from a field or a swatch. The popup holds a color area, a hue slider, a hex field, and an eyedropper.

  • Base UI
  • React Aria
  • React 19
  • Tailwind CSS 4

Added Nov 9, 2026 · MIT + Commons Clause

Playground

Loading the preview

Props

ColorPicker renders no element. It shares one color between the trigger and the popup. onValueChange gets a Color object, not a string.

fill-color.tsx

ColorPicker

PropTypeDefaultDescription
valuestring | Color—The current value (controlled).
defaultValuestring | Color—The default value (uncontrolled).
slotstring | null—A slot name for the component. Slots allow the component to receive props from a parent component. An explicit null value indicates that the local props completely override all props received from a parent.
onValueChange—Runs on each change, with the new value and the Base UI change details.
children—The trigger, the content, or inline color components. A function gets { color }.
labels—The words (COLOR_PICKER_LABELS), to translate them. Keep the object stable.
From Base UIPopover.RootBase UI docs
defaultOpenbooleanfalseWhether the popover is initially open. To render a controlled popover, use the open prop instead.
openboolean—Whether the popover is currently open.
onOpenChange—Event handler called when the popover is opened or closed.

ColorPickerTrigger

<button>
PropTypeDefaultDescription
classNamestring—
variant"field""swatch""field"field (default): a field with a swatch, the hex value, and a chevron. swatch: a 32px outline icon button with a 24px swatch. It has one size.
size"default""lg""sm""default"The height of the field: sm 28, default 32, lg 36.
From Base UIPopover.TriggerBase UI docs
idstring—ID of the trigger. In addition to being forwarded to the rendered element, it is also used to specify the active trigger for the popover in controlled mode (with the PopoverRoot triggerId prop).
handlePopoverHandle<unknown>—A handle to associate the trigger with a popover.
payloadunknown—A payload to pass to the popover when it is opened.
...props<button> attributes—Every other attribute goes to the <button>, with a ref.

ColorPickerContent

<div>
PropTypeDefaultDescription
classNamestring—
arrowboolean—Show an arrow that points at the trigger. The gap grows from 4px to 8px.
backdropboolean—Put a clear layer under the popup (Base UI Popover.Backdrop), for example to dim it.
showCloseButtonboolean—Show a close button (a 24px ghost icon button) 10px from the top and the end.
padding"default""none""tight"—default: radius 14, 12px padding and 10px between the parts, 288px wide. tight: 4px padding and 4px between the parts, as wide as the content: a row of 28px actions (a plain Toolbar) with the 4px inset of the bar recipe, 38px high (the selection pill of the Quote Reply). none: no padding and no gap, as wide as the content: a panel that lays out its own parts edge to edge (a head with a rule, a scroll box, a docked composer: the Chat Popup). Give it a width and a height with layout classes; the body fills that height.
portalProps—Other Base UI props of the inner parts. A className here adds to the component classes.
positionerProps—
backdropPropsPopupPartProps<PopoverBackdropProps>—
arrowPropsPopupPartProps<PopoverArrowProps>—
closeButtonProps—
closeLabelstring—The accessible name of the close button. Translate it with the page.
From Base UIPopover.PopupBase UI docs
initialFocus—Determines the element to focus when the popover is opened. By default, focus moves to the first tabbable element inside the popup, except when the popover is opened by touch — then the popup itself is focused to avoid opening the virtual keyboard. - false: Do not move focus. - true: Move focus based on the default behavior (first tabbable element or popup). - RefObject: Move focus to the ref element. - function: Called with the interaction type (mouse, touch, pen, or keyboard). Return an element to focus, true to use the default behavior, null to fall back to the default behavior, or false/undefined to do nothing.
finalFocus—Determines the element to focus when the popover is closed. - false: Do not move focus. - true: Move focus based on the default behavior (trigger or previously focused element). - RefObject: Move focus to the ref element. - function: Called with the interaction type (mouse, touch, pen, or keyboard). Return an element to focus, true to use the default behavior, null to fall back to the default behavior, or false/undefined to do nothing.
anchor—An element to position the popup against. By default, the popup will be positioned against the trigger.
...props<div> attributes—Every other attribute goes to the <div>, with a ref.

ColorPickerEyeDropper

<button>
PropTypeDefaultDescription
classNamestring—
busyboolean—The button waits for the app (busy words): a spinner, aria-busy, and no clicks. Focus stays on the button. The style hook stays data-loading.
spinnerPlacement"center""start"—center (default): the spinner covers the label. start: it takes the leading icon slot. The icon sizes always use center, because their one icon is the label.
glass"clear""dark""light"—
rounded"default""full"—
childrenReactNode—The icon. Default: a pipette.
onPickError—Runs when the browser EyeDropper fails (not on a cancel). Show the user a message here. With no handler, the error goes to the nearest error boundary.
From Base UIButtonBase UI docs
focusableWhenDisabledbooleanfalseWhether the button should be focusable when disabled.
render—Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render.
style—Style applied to the element, or a function that returns a style object based on the component's state.
...props<button> attributes—Every other attribute goes to the <button>, with a ref.
  • Use it when people pick any color, not a color from a short list.
  • Use ColorPickerTrigger with variant="field" in a form, or variant="swatch" in a toolbar.
  • Use ColorPickerContent with no children to get the default editor.
  • Pass your own children to ColorPickerContent for channel sliders or an alpha slider.
  • Put the color parts directly in ColorPicker for an inline editor with no popover.
EnterorSpaceOn ColorPickerTrigger: opens the popover.
EscapeCloses the popover.
Arrow keysColorArea thumb: moves the thumb one step on each axis. With Shift, it moves a large step.
Arrow keysColorSlider thumb: moves the thumb one step. With Shift, it moves a large step.
EnterColorField: sets the typed value.

Name the trigger with aria-labelledby, which keeps the color in the name. aria-label replaces the name.

Every control in the popup works with the keyboard, and focus goes back to the trigger on close.

ColorPickerEyeDropper renders nothing where the browser has no EyeDropper API.

Open
popup · 150ms · ease-panel (0.2, 0.4, 0.2, 1) · fades in and scales from 95%
Close
popup-exit · 120ms · ease-out (0, 0, 0.2, 1)
  1. AddedColor Picker, with Animated Chevrons Up Down Icon, Button, Color Area, Color Field, Color Slider, Color Swatch, Popover.
Open the release