Skip to content

Instantly share code, notes, and snippets.

@BeardedGinger
Created January 1, 2023 05:21
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Color Palette Example
import { InspectorControls, useSetting } from '@wordpress/block-editor';
import { PanelBody, PanelRow, ColorPalette } from '@wordpress/components';
const Edit = () => {
const { bgColor } = attributes;
const colors = useSetting( 'color.palette' ) || [];
return (
<>
<InspectorControls>
<PanelBody title='Background Options' initialOpen>
<PanelRow>
<ColorPalette
colors={ colors }
value={ bgColor }
onChange={ ( value ) => { setAttributes( { bgColor: value } ) } }
/>
</PanelRow>
</PanelBody>
</InspectorControls>
</>
);
}
export default Edit;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment