InnerBlocks component. This pattern is used in blocks like Columns, Group, Cover, and any block where you want to nest content.
A single block can only contain one
InnerBlocks component.Basic Usage
Here’s the simplest implementation of InnerBlocks:InnerBlocks.Content
In thesave function, use <InnerBlocks.Content /> to render the saved inner blocks:
Controlling Allowed Blocks
Limit which blocks can be inserted as children:Dynamic Allow List
Use theallowedBlocks prop for dynamic control:
Static Allow List
For a fixed list, use theallowedBlocks setting in block.json:
Block Templates
Prefill InnerBlocks with a default template:Template Locking
Control how users can modify the template:all- Prevents all operations (no insert, move, or delete)insert- Prevents inserting/removing blocks (allows reordering)contentOnly- Only allows editing block contentfalse- No locking (default)
Complete Template Example
Nested Templates
Templates can include nested inner blocks:Orientation
For horizontally-styled blocks, set the orientation:- Displays block movers horizontally
- Ensures drag and drop works correctly
- Doesn’t affect the actual layout (use CSS for that)
Default Block
Specify which block is inserted when the user clicks the appender:directInsert prop makes the default block insert immediately without showing the block picker.
Block Relationships
Control where blocks can be inserted using parent/child relationships.Parent Relationship
A block can only be a direct child of specified parents:Ancestor Relationship
A block can be anywhere in the tree under specified ancestors:Allowed Blocks (Children)
Specify which blocks can be direct children:Comparison
Using useInnerBlocksProps Hook
For more control over markup, use theuseInnerBlocksProps hook:
Merging Props
You can mergeblockProps and innerBlocksProps:
Accessing Children
Destructurechildren to add elements alongside inner blocks:
Complete Hook Example
Post Templates vs InnerBlocks Templates
InnerBlocks Template
Defines default blocks inside a specific block:Post Template
Defines default blocks for an entire post type:Complete Example: Testimonial Block
Best Practices
- One InnerBlocks per block: You can only have one InnerBlocks component per block
-
Always use InnerBlocks.Content: In the save function, use
<InnerBlocks.Content />not<InnerBlocks /> - Consider template locking: Decide if users should modify the structure
- Use semantic HTML: Choose appropriate wrapper elements (div, section, article, etc.)
- Test deeply nested scenarios: Ensure your block works when nested multiple levels deep
- Provide clear templates: Make placeholder text descriptive
Common Patterns
Two-Column Layout
Hero Section
Related Documentation
- Block Templates - Post-level templates
- Dynamic Blocks - InnerBlocks in dynamic blocks
- Block Patterns - Reusable block combinations
- InnerBlocks README - Component API reference