AI writes the code. You make the right choice for the user.
Every block can put its UI in two places. BlockControls adds buttons to the block toolbar, right above the selected block. InspectorControls adds panels to the Block tab of the settings sidebar. The code for both is short; the decision is what matters: actions on top, settings on the side.
Group: Block slots · Package: @wordpress/block-editor · Used in: a block’s edit
What they are
- `BlockControls`: the block toolbar. It appears only when the block is selected, right where the author is working. Usually holds
ToolbarGroup→ToolbarButton, aToolbarDropdownMenuor a small popover. - `InspectorControls`: the Block tab of the settings sidebar. Usually holds
PanelBodysections with form fields.
Both are slots: you render them inside your block’s edit, and the editor moves their content to the right place.

Real plugins use both
Every 4WP plugin with a custom block UI splits it the same way.
| Plugin | Toolbar (BlockControls) | Sidebar (InspectorControls) |
|---|---|---|
| 4WP FAQ | Unwrap 4WP FAQ; Convert to 4WP FAQ (on an Accordion) | SEO → JSON-LD on front end (Default / On / Off for this block) |
| 4WP Advanced Code (Terminal) | Configuration file | Terminal settings (Welcome message); Display modes (Full view button, Sticky panel button) |
| 4WP Smart Link | Smart Link (whole block): Custom Link, Post Link, Enlarge on click | Open in new tab, Mark as nofollow, Accessibility label |

Which one?
Ask two questions: how often and how many fields.
| Need | Slot |
|---|---|
| A frequent action, one click: toggle, convert, align, pick a file | BlockControls |
| Several fields, set once: SEO, labels, advanced options | InspectorControls |
| Settings for the whole post, not one block | `PluginDocumentSettingPanel` |
| Tools for the whole document | `PluginSidebar` |
Count the clicks
| Where | Actions |
|---|---|
| Toolbar | 1: it is already above the selected block |
| Sidebar, open | 2: Block tab → panel → field |
| Sidebar, closed | 3: settings → Block tab → panel |
Distance is a cost too: the toolbar is where the author’s eyes already are. Put the daily action there, and the rare setting in the sidebar.
Business value
Frequent actions one click away mean faster editing and fewer support questions about “where is that button”. Rare settings in the sidebar keep the toolbar short, so authors are not afraid of the block.
The code
import { BlockControls, InspectorControls, useBlockProps } from '@wordpress/block-editor';
import { PanelBody, SelectControl, ToolbarButton, ToolbarGroup } from '@wordpress/components';
function Edit( { attributes, setAttributes } ) {
return (
<>
<BlockControls>
<ToolbarGroup>
<ToolbarButton label="Unwrap" onClick={ unwrap } />
</ToolbarGroup>
</BlockControls>
<InspectorControls>
<PanelBody title="SEO">
<SelectControl
label="JSON-LD on front end"
value={ attributes.jsonLd }
options={ [ { label: 'Default', value: '' }, { label: 'On', value: 'enable' }, { label: 'Off', value: 'disable' } ] }
onChange={ ( jsonLd ) => setAttributes( { jsonLd } ) }
/>
</PanelBody>
</InspectorControls>
<div { ...useBlockProps() }>…</div>
</>
);
}
The full picture: hooks, methodology, architecture
Hooks: from a block setting to the page
A block setting is an attribute saved in the block’s markup. On the server, PHP reads it when the page renders.
| Job | Hook | In the plugins |
|---|---|---|
Register the block (and its attributes) from block.json | `init` | 4WP FAQ registers its block |
| Load the editor scripts with the toolbar and sidebar UI | `enqueue_block_editor_assets` | 4WP FAQ and 4WP Smart Link editor scripts |
| Change a block’s output based on its settings | `render_block` | 4WP Smart Link: render_block_core/image applies the lightbox set in the toolbar |
| Print data collected from block settings | `wp_head` | 4WP FAQ prints FAQPage JSON-LD, respecting the per-block “JSON-LD on front end” setting |
On the JavaScript side, 4WP Smart Link adds its attributes and UI to core blocks with two editor filters: blocks.registerBlockType (attributes) and editor.BlockEdit (toolbar and sidebar).
Methodology: where the UI goes is part of the design
- [SDD](https://4wp.dev/methodologies/sdd/): list every control with frequency and field count. “Unwrap: often, 1 click → toolbar. JSON-LD mode: once, 3 options → sidebar.” That table is the UI spec.
- [DDD](https://4wp.dev/methodologies/domain-driven-design/): name controls in the business language. “Convert to 4WP FAQ”, “Mark as nofollow”, “Configuration file”: the label says what happens, not how.
- [TDD](https://4wp.dev/methodologies/tdd/): test the attributes, not the buttons. The lesson checks
block.jsonattributes:highlightedfor the toolbar,notefor the sidebar. - Build or refactor. If authors open the sidebar every time for the same option, move it to the toolbar. If the toolbar has more than a few buttons, move the rare ones to the sidebar.
Related: Block-first / Gutenberg-first · Component-Driven Development
Architecture
Toolbar and sidebar are two views of the same block attributes; save or a PHP render is the output. Views, data, output: the same separation as in MVC & Layers.
Learn it in the Lesson IDE
The lesson block has one toolbar button (Highlight, a frequent toggle) and one sidebar field (Note, set once).

Files in the lesson:
index.js:BlockControls→ToolbarButton(Highlight) +InspectorControls→PanelBody→TextControl(Note)block.json: attributeshighlightedandnoteREADME.md: the decision card__tests__/
Learn Gutenberg Development on GitHub
Frequently Asked Questions
When the block is selected. That is why it fits actions on the current block, not settings the author needs elsewhere.
Yes. Add attributes with the blocks.registerBlockType filter and wrap the core block’s edit with the editor.BlockEdit filter to render BlockControls and InspectorControls. 4WP Smart Link adds its toolbar and sidebar to core blocks this way.
When authors have to search the toolbar, it is too many. Keep the daily actions there and move the rest to the sidebar.
In InspectorControls, often in a separate PanelBody that starts closed, or in the advanced group of the inspector.
InspectorControls is for one block. PluginDocumentSettingPanel is for the whole post.
Next in the series
- [PluginPrePublishPanel](https://4wp.dev/components/plugin-pre-publish-panel/): the last check before publishing
- PanelBody vs ToolsPanel: how to organize a panel
Components are the alphabet. UX is the sentence.