Created
January 1, 2023 05:21
-
-
Save BeardedGinger/cb0ce495e063060523a9341d2a41e967 to your computer and use it in GitHub Desktop.
Color Palette Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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