@wordpress/block-library package contains the implementation of all core WordPress blocks. It provides a single function to register all core blocks at once.
Installation
Basic Usage
Register All Core Blocks
- Paragraph
- Heading
- Image
- List
- Quote
- Code
- And many more…
Load Required Styles
Don’t forget to load the block stylesheets:Registering Individual Blocks
You can also register blocks individually for more control:Method 1: Auto-register on Import
Method 2: Get Block Reference
Method 3: Manual Control
Core Blocks Included
The block library includes implementations for:Text Blocks
- Paragraph
- Heading
- List
- Quote
- Code
- Preformatted
- Pullquote
- Verse
Media Blocks
- Image
- Gallery
- Audio
- Video
- File
- Media & Text
- Cover
Design Blocks
- Button/Buttons
- Columns
- Group
- Row
- Stack
- Separator
- Spacer
Layout Blocks
- Template Part
- Navigation
- Site Logo
- Site Title
- Site Tagline
Embed Blocks
- Embed (with variations for YouTube, Twitter, etc.)
Widget Blocks
- Archives
- Calendar
- Categories
- Latest Comments
- Latest Posts
- Page List
- RSS
- Search
- Tag Cloud
Theme Blocks
- Query
- Post Content
- Post Title
- Post Featured Image
- Post Excerpt
- Post Date
- Post Author
- Comments
Custom Block Development
When building custom blocks, you can use this package as a reference for best practices and patterns used in core blocks.Example: Studying Core Block Implementation
Adding Core Blocks to Custom Editors
When building a custom block editor, register core blocks before initializing:Selective Block Registration
You can choose which blocks to register:Block Styles
Core blocks come with three stylesheet types:- style.css - Styles for both editor and frontend
- editor.css - Editor-only styles
- theme.css - Theme-dependent styles
Environment Requirements
This package requires an ES2015+ environment. Include the polyfill from@wordpress/babel-preset-default if needed.
Contributing
When adding new core blocks, additional steps are required:- Register the block in the package’s
index.js - Add it to
lib/blocks.phpin Gutenberg - Create an
init.jsfile in the block directory - Add script modules to
package.jsonif needed