Home » Placeholder — The Empty State That Leads to the First Action

Placeholder — The Empty State That Leads to the First Action

Home » Placeholder — The Empty State That Leads to the First Action

Placeholder — The Empty State That Leads to the First Action

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…

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.

The Placeholder lesson block: label and instructions in the canvas, the message field in the block sidebar.
The Placeholder lesson block: label and instructions in the canvas, the message field in the block sidebar.

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

NeedBetter choice
The block already has contentRender the content; move settings to InspectorControls
Waiting for dataSpinner
Something went wrongNotice
Upload, media library or URL for an image or fileMediaPlaceholder from @wordpress/block-editor (built on Placeholder)

Count the clicks

Where the first step livesActions to start
Placeholder with the action inside1 click, right in the canvas
Setting in the block sidebar2–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

JAVASCRIPT
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

JobHookIn 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

index.js: Placeholder in edit, InspectorControls for the message.
index.js: Placeholder in edit, InspectorControls for the message.
README.md: what the lesson covers.
README.md: what the lesson covers.

Files in the lesson:

  • index.js: registerBlockType, edit with Placeholder and InspectorControls, save
  • block.json: name, category, the message attribute
  • README.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

All Gutenberg Components

Components are the alphabet. UX is the sentence.

Build WordPress the right way

Production-ready 4WP plugins with clean architecture — or a team that builds it with you.

Latest videos

All videos →

Learn by topic