Skip to content
63 changes: 51 additions & 12 deletions storybook/stories/introduction.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Meta } from '@storybook/addon-docs/blocks';
import { Markdown, Meta } from '@storybook/addon-docs/blocks';
import { JumpToIcon } from '@storybook/icons';
import { InlineIcon } from './docs/inline-icon';

Expand All @@ -8,34 +8,73 @@ import { InlineIcon } from './docs/inline-icon';

## Welcome!

The WordPress Gutenberg project uses Storybook to view and work with the UI components developed in WordPress packages, especially [@wordpress/components](https://github.com/WordPress/gutenberg/tree/trunk/packages/components).
The WordPress Gutenberg project uses Storybook to view and work with the UI components developed in WordPress packages. Explore the [WordPress Design System](?path=/docs/design-system-introduction--docs) in this Storybook: its foundations, tokens, theme, patterns, and components.

On this interactive site you can browse individual components, their controls, options, and settings in isolation. You can also modify controls and arguments and see the changes right away.

The components displayed on this site can be used in your code to build the editor's UI for your custom blocks or other pages.
Import them from the components root directory like in below example:
The components displayed on this site can be used in your code to build the editor's UI for your custom blocks or other pages. The example below imports the `Button` component from `@wordpress/ui`:

```jsx
import { Button } from '@wordpress/components';
import { Button } from '@wordpress/ui';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ciampo @simison Are we close to marking the new Button as recommended? This may affect whether or not we want to start showcasing this snippet here, which will currently trigger a lint rule.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last I recall the only soft blocker we had was some migration documentation.

#76135 (comment)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if we should consider the (remaining) misalignment between components and ui Button here — #82506 for context.


export default function MyButton() {
return <Button>Click Me!</Button>;
return <Button>Click me</Button>;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice fix for style adherence 👍

}
```

## What you'll find here

The sidebar has one folder per area:

- **Design System** holds what the components are built from: the [tokens](?path=/docs/design-system-tokens-introduction--docs) and [theme](?path=/docs/design-system-theme-introduction--docs) from `@wordpress/theme`, the [patterns](?path=/docs/design-system-patterns-destructive-actions--docs) for composing UI, and the [foundations](?path=/docs/foundations-layout--page) of layout, elevation and radius.
- **Components** documents both component packages. Start with [`@wordpress/ui`](?path=/docs/design-system-components-introduction--docs), the recommended toolkit for new UI; `@wordpress/components` is the original WordPress UI library, still widely used and still the place to look for what `@wordpress/ui` does not cover yet. Each component page shows its recommendation status; see [Finding your way around](#finding-your-way-around) for the icons.
- **Editor** documents UI of the WordPress editing experience: the block editor controls, global styles, the image cropper and the media editor.
- **Widgets** documents the dashboard widget system: its primitives, the dashboard shell, and the grid that lays widgets out.
- **Playground** runs a whole block editor inside Storybook.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessarily within the scope of this PR, but this reminds me that we should probably rename "Playground" here, as it now conflicts with WordPress Playground and is confusing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn’t find an earlier discussion about this. I agree that the Playground name is confusing now that WordPress Playground exists. A rename seems worth discussing in a separate issue, since it affects the sidebar structure rather than just the introduction copy.


## How this site works

The site shows the components in the sidebar. Each component's entry point is its **Docs** page, which contains the documentation and interactive examples. You can also explore the individual stories (e.g. "Default", "Small") to view a single use case on the **Canvas**, where you can modify the **Controls** for each prop in the panel below.
Each component's entry point is its **Docs** page, with the documentation and interactive examples. The individual stories (for example "Default" or "Small") show a single use case on the **Canvas**, where you can change the **Controls** for each prop in the panel below.

To view the source code for a component and its stories on GitHub, click the <InlineIcon icon={ JumpToIcon } /> (Open source file) button in the top toolbar.

### Finding your way around

The sidebar lists everything on this site. Use the search box (⌘K / Ctrl+K) to find a component by name, or open the filter menu next to it to show only the entries with a given tag.

To view the source code for the component and its stories on GitHub, click the <InlineIcon icon={ JumpToIcon } /> (Open source file) button in the top toolbar.
Component names carry an icon with their status. The same statuses are available as tags in the filter, so you can, for example, show recommended components only.

To use it in your local development environment run the following command in the top level Gutenberg directory:
<Markdown>{ `
| Icon | Tag | Meaning |
| ---- | ------------------------- | -------------------------------------------------------------------------------- |
| ✅ | \`use-recommended\` | Use this component for new UI. |
| ⚠️ | \`use-with-caution\` | Use with care; check the notes on the component page. |
| 🚫 | \`use-not-recommended\` | Do not use for new UI. The component page points at the recommended alternative. |
| ❓ | \`use-unaudited\` | Not audited yet against the design system. |
| 🧪 | \`status-experimental\` | Under active development, may change in future releases. |
| 🔒 | \`status-private\` | Locked as a private API, not for use outside Gutenberg. |
| 🚧 | \`status-wip\` | Work in progress, not ready for production. |
` }</Markdown>

Hover an icon in the sidebar for the same description. Each component page also shows its status at the top.

### Running it locally

Use the following command in the top-level Gutenberg directory:

```bash
npm run storybook:dev
```

## Resources to learn more:
## Using it with AI agents

The [WordPress Design System MCP Server](https://github.com/WordPress/gutenberg/tree/trunk/packages/design-system-mcp) gives AI agents direct, machine-readable access to the component documentation, examples, and design tokens available on this site. Agents can use it to find recommended components and valid tokens.

The [package README](https://github.com/WordPress/gutenberg/tree/trunk/packages/design-system-mcp#setup) covers installation for Claude Code, Codex, Cursor, VS Code and Claude Desktop.

## Resources to learn more

- [Storybook.js.org](https://storybook.js.org/) - Storybook is a frontend workshop for building UI components and pages in isolation.
- [[Package] Components](https://github.com/WordPress/gutenberg/issues?q=is%3Aopen+is%3Aissue+label%3A%22%5BPackage%5D+Components%22) - Open Issue Gutenberg Repo
- [Working with WordPress Design System packages](https://developer.wordpress.org/block-editor/contributors/design/design-system-packages/) in the Block Editor Handbook.
- [ESLint rules for the design system](https://github.com/WordPress/gutenberg/tree/trunk/packages/eslint-plugin/docs/rules): `@wordpress/eslint-plugin` warns when your code uses a component that is no longer recommended or a design token that does not exist.
- [Storybook.js.org](https://storybook.js.org/), the tool this site is built with.
- Open issues for the [design system](https://github.com/WordPress/gutenberg/issues?q=is%3Aopen+is%3Aissue+label%3A%22Design+System%22) and for [`@wordpress/components`](https://github.com/WordPress/gutenberg/issues?q=is%3Aopen+is%3Aissue+label%3A%22%5BPackage%5D+Components%22) in the Gutenberg repository.
Loading