ColorPalette Edit

ColorPalette allows the user to pick a color from a list of pre-defined color entries.


import { ColorPalette } from '@wordpress/components';
import { useState } from '@wordpress/element';

const MyColorPalette = () => {
    const [ color, setColor ] = useState ( '#f00' )
    const colors = [
        { name: 'red', color: '#f00' },
        { name: 'white', color: '#fff' },
        { name: 'blue', color: '#00f' },

    return (
            colors={ colors }
            value={ color }
            onChange={ ( color ) => setColor( color ) }
} );

If you’re using this component outside the editor, you can
ensure Tooltip positioning
for the ColorPalette‘s color swatches, by rendering your ColorPalette with a
Popover.Slot further up the element tree and within a
SlotFillProvider overall.

Top ↑


The component accepts the following props.

Top ↑

clearable: boolean

Whether the palette should have a clearing button.

  • Required: No
  • Default: true

Top ↑

colors: ( PaletteObject | ColorObject )[]

Array with the colors to be shown. When displaying multiple color palettes to choose from, the format of the array changes from an array of colors objects, to an array of color palettes.

  • Required: No
  • Default: []

Top ↑

disableCustomColors: boolean

Whether to allow the user to pick a custom color on top of the predefined
choices (defined via the colors prop).

  • Required: No
  • Default: false

Top ↑

enableAlpha: boolean

This controls whether the alpha channel will be offered when selecting custom

  • Required: No
  • Default: false

Top ↑

value: string

Currently active value.

  • Required: No

Top ↑

onChange: OnColorChange

Callback called when a color is selected.

  • Required: Yes