What are the Inspector Controls?
The Inspector Controls are the settings in the sidebar of Gutenberg blocks. When a block is selected in admin, you will see the settings of the blocks under the ‘Block‘ tab of the sidebar. Typical settings you will find here are color selectors, on/off switches, size selectors, and variable dropdowns.

The Inspector Control React Component
For the WordPress developer, the Inspector Controls (<InspectorControls>) is a React component used within the edit-function of a Gutenberg block. Any child of the Inspector Controls will show up in the sidebar while editing the block in the WordPress admin. Below is a minimal edit function of a Gutenberg block using a ‘ToggleControl‘ control (switch on/off) inside the inspector controls.
import { InspectorControls } from '@wordpress/block-editor';
import { PanelBody, ToggleControl } from '@wordpress/components';
const Edit = ({ attributes, setAttributes }) => (
<>
<InspectorControls>
<PanelBody title="Settings">
<ToggleControl label="Show text?"
checked={Boolean(attributes.show)}
onChange={(show) => setAttributes({ show })} />
</PanelBody>
</InspectorControls>
<div>My block content</div>
</>
);
Inside of the <InspectorControls> you find a wrapper component called <PanelBody>. It divides the settings area into sections that can be toggled to open and close.
Inside of the <PanelBody> is the actual wordpress native form control. You may use a regular html checkbox instead – but it gives a consistent feeling to stick to the native wordpress controls available in the WordPress components library.
You will use the control components to set your block attributes (the data that is saved in the database and passed to the save function).
Hoped this gave an introduction to the settings panel of Gutenberg blocks. In the coming posts, we will go through the most useful controls in the components library. Stay tuned!
Attribute defaults
Declare show as a boolean attribute in the block registration or metadata. Set a default so the editor begins in a predictable state. Changing an attribute does not by itself change the saved output: the save or render function must use that value.



