# @wordpress/block-library

> Block library for the WordPress editor.

Latest version **12.2.0** (published 2026-11-18) · GPL-2.0-or-later license · 0 weekly downloads

## Install

```sh
npm install @wordpress/block-library
pnpm add @wordpress/block-library
yarn add @wordpress/block-library
bun add @wordpress/block-library
```

## Health

**Score 68/100 (B)** — status: active.

Positive: has types package; esm support; no vulnerabilities; recently updated; high maintenance score; popular repo.

Warnings: low downloads; large bundle.

## Facts

| | |
|---|---|
| Version | 12.2.0 |
| Published | 2026-11-18 |
| First published | 2018-08-13 |
| Weekly downloads | 0 |
| License | GPL-2.0-or-later |
| TypeScript types | separate (@types/wordpress__block-library) |
| Module format | ESM + CommonJS |
| Node | >=22.13.0 |
| Dependencies | 46 |
| Unpacked size | 16.8 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 11791 |
| Author | The WordPress Contributors |
| Maintainers | garypendergast, adamsilverstein, gziolo, ntwb, riad, noisysocks, kadamwhite, gutenbergplugin, jorgefilipecosta, ellatrix, iandunn206, whyisjake, ockham, sirreal, nosolosw, wpisabel, ntsekouras, nerrad, desrosj, talldanwp, peterwilsoncc, ryanwelcher, mamaduka, aduth, johnbillion |
| Keywords | wordpress, gutenberg, blocks |

## Links

- npm: https://www.npmjs.com/package/@wordpress/block-library
- Repository: https://github.com/WordPress/gutenberg
- Homepage: https://github.com/WordPress/gutenberg/tree/HEAD/packages/block-library/README.md
- Issues: https://github.com/WordPress/gutenberg/issues
- npm.io page: https://npm.io/package/@wordpress/block-library

## Dependencies (46)

- [clsx](https://npm.io/package/clsx.md) ^2.1.1
- [uuid](https://npm.io/package/uuid.md) ^14.0.0
- [colord](https://npm.io/package/colord.md) ^2.9.4
- [memize](https://npm.io/package/memize.md) ^2.1.1
- [change-case](https://npm.io/package/change-case.md) ^4.1.2
- [@wordpress/ui](https://npm.io/package/@wordpress/ui.md) ^0.27.0
- [@wordpress/dom](https://npm.io/package/@wordpress/dom.md) ^5.2.0
- [@wordpress/url](https://npm.io/package/@wordpress/url.md) ^5.2.0
- [@wordpress/a11y](https://npm.io/package/@wordpress/a11y.md) ^5.2.0
- [@wordpress/blob](https://npm.io/package/@wordpress/blob.md) ^5.2.0
- [@wordpress/data](https://npm.io/package/@wordpress/data.md) ^11.2.0
- [@wordpress/date](https://npm.io/package/@wordpress/date.md) ^6.2.0
- [@wordpress/i18n](https://npm.io/package/@wordpress/i18n.md) ^7.2.0
- [@wordpress/autop](https://npm.io/package/@wordpress/autop.md) ^5.2.0
- [@wordpress/hooks](https://npm.io/package/@wordpress/hooks.md) ^5.2.0
- [@wordpress/icons](https://npm.io/package/@wordpress/icons.md) ^21.0.0
- [@wordpress/blocks](https://npm.io/package/@wordpress/blocks.md) ^17.2.0
- [html-react-parser](https://npm.io/package/html-react-parser.md) ^5.2.11
- [@wordpress/compose](https://npm.io/package/@wordpress/compose.md) ^9.2.0
- [@wordpress/element](https://npm.io/package/@wordpress/element.md) ^10.2.0
- [@wordpress/notices](https://npm.io/package/@wordpress/notices.md) ^6.2.0
- [fast-average-color](https://npm.io/package/fast-average-color.md) ^9.1.1
- [@wordpress/keycodes](https://npm.io/package/@wordpress/keycodes.md) ^5.2.0
- [@wordpress/patterns](https://npm.io/package/@wordpress/patterns.md) ^3.2.0
- [@wordpress/api-fetch](https://npm.io/package/@wordpress/api-fetch.md) ^8.2.0
- [@wordpress/core-data](https://npm.io/package/@wordpress/core-data.md) ^9.2.0
- [@wordpress/rich-text](https://npm.io/package/@wordpress/rich-text.md) ^8.2.0
- [@wordpress/shortcode](https://npm.io/package/@wordpress/shortcode.md) ^5.2.0
- [@wordpress/wordcount](https://npm.io/package/@wordpress/wordcount.md) ^5.2.0
- [@wordpress/components](https://npm.io/package/@wordpress/components.md) ^45.0.0
- [@wordpress/deprecated](https://npm.io/package/@wordpress/deprecated.md) ^5.2.0
- [@wordpress/kebab-case](https://npm.io/package/@wordpress/kebab-case.md) ^2.2.0
- [@wordpress/primitives](https://npm.io/package/@wordpress/primitives.md) ^5.2.0
- [@wordpress/base-styles](https://npm.io/package/@wordpress/base-styles.md) ^15.1.0
- [@wordpress/escape-html](https://npm.io/package/@wordpress/escape-html.md) ^4.2.0
- [@wordpress/block-editor](https://npm.io/package/@wordpress/block-editor.md) ^20.1.0
- [@wordpress/private-apis](https://npm.io/package/@wordpress/private-apis.md) ^3.2.0
- [@wordpress/upload-media](https://npm.io/package/@wordpress/upload-media.md) ^0.45.0
- [@wordpress/html-entities](https://npm.io/package/@wordpress/html-entities.md) ^5.2.0
- [@wordpress/interactivity](https://npm.io/package/@wordpress/interactivity.md) ^8.2.0
- [@wordpress/latex-to-mathml](https://npm.io/package/@wordpress/latex-to-mathml.md) ^2.2.0
- [@arraypress/waveform-player](https://npm.io/package/@arraypress/waveform-player.md) ^1.27.0
- [@wordpress/react-inert-value](https://npm.io/package/@wordpress/react-inert-value.md) ^2.2.0
- [@wordpress/server-side-render](https://npm.io/package/@wordpress/server-side-render.md) ^7.2.0
- [@wordpress/global-styles-engine](https://npm.io/package/@wordpress/global-styles-engine.md) ^2.2.0
- [@wordpress/interactivity-router](https://npm.io/package/@wordpress/interactivity-router.md) ^3.2.0

## Recent versions

- 12.2.0 (latest) — 2026-11-18
- 9.33.13 (wp-6.9) — 2026-11-18
- 9.0.11 (wp-6.6) — 2026-11-18
- 8.12.23 (wp-6.3) — 2026-11-18
- 8.28.15 (wp-6.5) — 2026-11-18
- 9.19.9 (wp-6.8) — 2026-11-18
- 9.8.20 (wp-6.7) — 2026-11-18
- 8.3.19 (wp-6.2) — 2026-11-18
- 7.14.18 (wp-6.1) — 2026-11-18
- 7.3.22 (wp-6.0) — 2026-11-18
- 8.19.21 (wp-6.4) — 2026-11-18
- 2.28.14 (wp-5.7) — 2026-11-18
- 2.22.13 (wp-5.5) — 2026-11-18
- 6.0.34 (wp-5.9) — 2026-11-18
- 2.26.12 (wp-5.6) — 2026-11-18
- … 567 more at https://npm.io/package/@wordpress/block-library/versions

## README

# Block library

Block library for the WordPress editor.

## Installation

Install the module

```bash
npm install @wordpress/block-library --save
```

_This package assumes that your code will run in an **ES2015+** environment. If you're using an environment that has limited or no support for such language features and APIs, you should include [the polyfill shipped in `@wordpress/babel-preset-default`](https://github.com/WordPress/gutenberg/tree/HEAD/packages/babel-preset-default#polyfill) in your code._

## API

<!-- START TOKEN(Autogenerated API docs) -->

### registerCoreBlocks

Function to register core blocks provided by the block editor.

_Usage_

```js
import { registerCoreBlocks } from '@wordpress/block-library';

registerCoreBlocks();
```

_Parameters_

- _blocks_ `Array`: An optional array of the core blocks being registered.

<!-- END TOKEN(Autogenerated API docs) -->

## Registering individual blocks

1.  When you only care about registering the block when file gets imported:

    ```js
    import '@wordpress/block-library/build-module/verse/init';
    ```

2.  When you want to use the reference to the block after it gets automatically registered:

    ```js
    import verseBlock from '@wordpress/block-library/build-module/verse/init';
    ```

3.  When you need a full control over when the block gets registered:

    ```js
    import { init } from '@wordpress/block-library/build-module/verse';

    const verseBlock = init();
    ```

## Contributing to this package

This is an individual package that's part of the Gutenberg project. The project is organized as a monorepo. It's made up of multiple self-contained software packages, each with a specific purpose. The packages in this monorepo are published to [npm](https://www.npmjs.com/) and used by [WordPress](https://make.wordpress.org/core/) as well as other software projects.

To find out more about contributing to this package or Gutenberg as a whole, please read the project's main [contributor guide](https://github.com/WordPress/gutenberg/tree/HEAD/CONTRIBUTING.md).

### Adding new blocks

⚠️ Adding new blocks to this package **requires** additional steps!

1.  Do not forget to register a new core block in the [`index.jsx`](https://github.com/WordPress/gutenberg/blob/trunk/packages/block-library/src/index.jsx) file of this package. For example, if you were to add the new core block called `core/blinking-paragraph`, you would have to add something like:

    ```js
    // packages/block-library/src/index.jsx
    import * as blinkingParagraph from './blinking-paragraph';
    ```

    Then add `blinkingParagraph` to the list in the `getAllBlocks()` function.

    If it's experimental, add the following property to `block.json`:

    ```json
    {
    	"__experimental": "true"
    }
    ```

2.  Register the block in the `gutenberg_reregister_core_block_types()` function of the [`lib/blocks.php`](https://github.com/WordPress/gutenberg/blob/trunk/lib/blocks.php) file. Add it to the `block_folders` array if it's a [static block](https://developer.wordpress.org/block-editor/getting-started/glossary/#static-block) or to the `block_names` array if it's a [dynamic block](https://developer.wordpress.org/block-editor/getting-started/glossary/#dynamic-block).

3.  Add `init.js` file to the directory of the new block:

    ```js
    import { init } from './';

    export default init();
    ```

    This file is used when using the option to register individual block from the `@wordpress/block-library` package.

4.  If the block exposes a script module on the front end, it must be included in the package's `package.json` file in the `wpScriptModules` object. This will include the script module when it's bundled for use in WordPress. See [the packages README for more details.](../README.md):

    ```json
    {
    	"name": "@wordpress/block-library",
    	"wpScriptModuleExports": {
    		"./blinking-paragraph/view": "./build-module/blinking-paragraph/view.js",
    		"./image/view": "./build-module/image/view.js"
    		// Add any new script modules here.
    	}
    }
    ```

    For every dynamic block, you need to manually enqueue the view script module in `render_callback` of the block, example:

    ```php
    function render_block_core_blinking_paragraph( $attributes, $content ) {
        $should_load_view_script = ! empty( $attributes['isInteractive'] );
        if ( $should_load_view_script ) {
    	    wp_enqueue_script_module( '@wordpress/block-library/blinking-paragraph' );
        }

    	return $content;
    }
    ```

### Naming convention for PHP functions

All PHP function names declared within the subdirectories of the `packages/block-library/src/` directory should start with one of the following prefixes:

- `block_core_<directory_name>`
- `render_block_core_<directory_name>`
- `register_block_core_<directory_name>`

In this context, `<directory_name>` represents the name of the directory where the corresponding `.php` file is located.
The directory name is converted to lowercase, and any characters except for letters and digits are replaced with underscores.

#### Example:

For the PHP functions declared in the `packages/block-library/src/my-block/index.php` file, the correct prefixes would be:

- `block_core_my_block`
- `render_block_core_my_block`
- `register_block_core_my_block`

#### Using plugin-specific prefixes/suffixes

Unlike in [PHP code in the /lib directory](https://github.com/WordPress/gutenberg/blob/trunk/lib/README.md), you should generally avoid applying plugin-specific prefixes/suffixes such as `gutenberg_` to functions and other code in block PHP files.

There are times, however, when blocks may need to use Gutenberg functions even when a Core-equivalent exists, for example, where a Gutenberg function relies on code that is only available in the plugin.

In such cases, you can use the corresponding Core `wp_` function in the block PHP code, and add its name to a list of prefixed functions in the package.json.

At build time, Webpack will search for `wp_` functions in that list and replace them with their `gutenberg_` equivalents. This process ensures that the plugin calls the `gutenberg_` functions, but the block will still call the Core `wp_` function when updates are back ported.

Webpack assumes that, prefixes aside, the functions' names are identical: `wp_get_something_useful()` will be replaced with `gutenberg_get_something_useful()`.

<br /><br /><p align="center"><img src="https://s.w.org/style/images/codeispoetry.png?1" alt="Code is Poetry." /></p>

---
_Source: https://npm.io/package/@wordpress/block-library · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
