Basic Usage
InnerBlocks exports a pair of components for theedit and save functions:
Complete Example: Section Block
block.jsonInnerBlocks Props
allowedBlocks
array | boolean
default:"true"
Restrict which block types can be inserted
Child blocks that mark themselves as compatible with a parent block are never excluded, even if not in
allowedBlocks.template
array
Predefined block structure to initialize InnerBlocks with
Nested Template
templateLock
string | boolean
Controls how users can modify the template structure
'all'- Prevents all operations (insert, move, delete)'insert'- Prevents inserting/removing, but allows moving'contentOnly'- Prevents all operations and hides non-content blocksfalse- No locking (default)
Real Example: Columns Block
Frompackages/block-library/src/columns:
block.json
orientation
'horizontal' | 'vertical'
default:"'vertical'"
Display direction for block movers and drag-and-drop
renderAppender
Component | false
Component to render at the end of the blocks list
Built-in Appenders
Custom Appender
placeholder
Component
Component shown before any blocks are added
defaultBlock
object
Default block type and attributes for new insertions
directInsert
boolean
default:"false"
Whether to insert the default block directly without showing the inserter
prioritizedInserterBlocks
array
Block types to show first in the inserter
templateInsertUpdatesSelection
boolean
default:"false"
Whether inserting template blocks updates the selection
Advanced Examples
Testimonial Block with Fixed Structure
Card Block with Specific Allowed Blocks
Accordion Item with Content Lock
Using with useInnerBlocksProps
For more advanced use cases, useuseInnerBlocksProps:
Real-World Example: Group Block
Frompackages/block-library/src/group:
block.json
Parent-Child Relationships
Use theparent property in block.json to restrict where a block can be used:
Child block (core/column):
Dynamic InnerBlocks (Server-side Rendering)
For dynamic blocks, InnerBlocks content is available in PHP:Block Appender Customization
Conditional Appender
Best Practices
Always include InnerBlocks.Content in save
Always include InnerBlocks.Content in save
The save function must render
<InnerBlocks.Content /> exactly where the edit function renders <InnerBlocks />.Use templates for consistent structure
Use templates for consistent structure
Templates help users start with the right block configuration and maintain consistency.
Restrict allowed blocks when appropriate
Restrict allowed blocks when appropriate
Use
allowedBlocks to prevent users from adding blocks that don’t work well in your layout.Consider template locking
Consider template locking
Lock templates when structure is important, but allow users to edit content.
Use parent/child relationships
Use parent/child relationships
Define parent constraints to ensure child blocks are only used where appropriate.
Common Patterns
Two-Column Layout
Media-Text Pattern
Accessing Inner Blocks Data
Use the block editor selectors to work with inner blocks:Next Steps
Block Patterns
Create reusable layouts with patterns
Block API Overview
Return to core Block API concepts