首先需要导入组件-
const {
PanelColorSettings,
} = wp.editor;
然后在
InspectorControls 您调用组件
<PanelColorSettings
title={ __( \'Color Settings\' ) }
colorSettings={ [
{
value: color,
onChange: ( colorValue ) => setAttributes( { color: colorValue } ),
label: __( \'Background Color\' ),
},
{
value: textColor,
onChange: ( colorValue ) => setAttributes( { textColor: colorValue } ),
label: __( \'Text Color\' ),
},
] }
>
</PanelColorSettings>