AI writes the code. You make the right choice for the user.
Placeholder is what a block shows before it has content: an icon, a label, a short instruction and, usually, the first action. Core uses it everywhere: an empty Image, Embed or Gallery block tells you what to do next instead of showing nothing. Your block should do the same.
Group: Layout · Package: @wordpress/components · Used in: a block’s edit
Placeholder: the Gutenberg component behind every empty block
What Placeholder is
A layout component for a block’s empty state in the editor. Its main props:
- `icon`: what the block is about
- `label`: the block’s name
- `instructions`: one sentence about the next step
- children: the action itself, for example a button, a select or a URL field
It lives in edit only. The saved front-end markup never contains a Placeholder.

When it fits
- A block needs setup before it can show anything: choose a source, connect an account, pick a post, paste a URL.
- The first action is obvious and single: one button or one field right where the author is looking.
- Onboarding: an editor who has never seen the block understands it without documentation.
When it doesn’t fit: pick this instead
| Need | Better choice |
|---|---|
| The block already has content | Render the content; move settings to InspectorControls |
| Waiting for data | Spinner |
| Something went wrong | Notice |
| Upload, media library or URL for an image or file | MediaPlaceholder from @wordpress/block-editor (built on Placeholder) |
Count the clicks
| Where the first step lives | Actions to start |
|---|---|
| Placeholder with the action inside | 1 click, right in the canvas |
| Setting in the block sidebar | 2–3: select the block, open the sidebar, find the panel |
| Nothing (an empty box) | The author has to guess, or ask support |
Business value
Fewer empty or broken blocks reach production, new editors start without training, and support gets fewer “the block is empty” tickets. An empty state is part of the product, not a gap in it.
The code
import { Placeholder } from '@wordpress/components';
import { useBlockProps } from '@wordpress/block-editor';
function Edit( { attributes } ) {
return (
<div { ...useBlockProps() }>
<Placeholder
icon="admin-generic"
label="Placeholder"
instructions={ attributes.message }
/>
</div>
);
}
In the lesson the instruction text comes from an attribute that the author edits in the block sidebar (InspectorControls → PanelBody → TextControl).
The full picture: hooks, methodology, architecture
Hooks: the PHP side of a block with an empty state
| Job | Hook | In the lesson plugin |
|---|---|---|
Register the block from block.json | `init` | register_block_type() for every build/blocks/*/block.json |
| Control what an empty block outputs on the front end | `render_block` | Not used yet: return '' for a block that was never set up |
The Placeholder itself is editor-only, so the front-end question is separate: an unfinished block should output nothing, not a broken box.
Methodology: design the states, not just the happy path
- [SDD](https://4wp.dev/methodologies/sdd/): list the states. Every block that loads or needs setup has at least four: empty, loading, ready, error. Write down which component shows each one (Placeholder, Spinner, the content, Notice) before writing code.
- [Content-first design](https://4wp.dev/methodologies/content-first-design/): the empty state is content too. Its one-line instruction is often the only documentation an editor reads.
- [TDD](https://4wp.dev/methodologies/tdd/): the lesson starts with metadata tests on
block.json(name, category, attributes, apiVersion), with no editor mocks needed. - Build or refactor. If authors keep opening the sidebar before a block shows anything, move that first step into a Placeholder.
Related: Block-first / Gutenberg-first · Component-Driven Development
Architecture
The block’s edit picks a view by state: Placeholder when empty, Spinner while loading, the content when ready. That is view selection by state, the same separation of concerns as in MVC & Layers.
Learn it in the Lesson IDE


Files in the lesson:
index.js:registerBlockType,editwith Placeholder and InspectorControls,saveblock.json: name, category, themessageattributeREADME.md__tests__/index.test.js: metadata tests
Learn Gutenberg Development on GitHub · Open in Playground
Frequently Asked Questions
No. It is rendered in the block’s edit function only. Decide separately what the block saves or renders when it was never set up.
For images, video, audio or files use MediaPlaceholder from @wordpress/block-editor: it adds upload, media library and URL input on top of Placeholder. For any other first step use Placeholder.
One clear action: a button, a select or a field. If you need a form with many fields, the block probably needs a sidebar panel instead.
Use a Spinner for loading and a Notice for errors. Keep Placeholder for “nothing here yet, here is how to start”.
Next in the series
- [PluginSidebar](https://4wp.dev/components/plugin-sidebar/): your own panel for whole-document tools
- [PluginDocumentSettingPanel](https://4wp.dev/components/plugin-document-setting-panel/): the 0-click shelf in the Page tab
Components are the alphabet. UX is the sentence.