ColorPicker


目录

ColorPicker is a color picking component based on react-colorful. It lets you pick a color visually or by manipulating the individual RGB(A), HSL(A) and Hex(8) color values.

Usage

import { useState } from 'react';
import { ColorPicker } from '@wordpress/components';

function Example() {
    const [color, setColor] = useState();
    return (
        <ColorPicker
            color={color}
            onChange={setColor}
            enableAlpha
            defaultValue="#000"
        />
    );
}

Props

color: string

The current color value to display in the picker. Must be a hex or hex8 string.

onChange: (hex8Color: string) => void

Fired when the color changes. Always passes a hex or hex8 color string.

enableAlpha: boolean

When true the color picker will display the alpha channel both in the bottom inputs as well as in the color picker itself.

defaultValue: string | undefined

An optional default value to use for the color picker.

copyFormat: 'hex' | 'hsl' | 'rgb' | undefined

The format to copy when clicking the displayed color format.


版本号 #2
由 壳壳虫 创建于 2026-10-31 18:12:36 UTC
由 壳壳虫 更新于 2026-10-31 18:12:37 UTC