storybook/docs/writing-docs/doc-blocks.md
Kyle Gach c03f0da058 Add Doc Blocks overview & API reference
- Remove Doc Blocks guides
- Update `docs/api/argtypes` to include information that was in `docs/writing-docs/doc-block-argstable`
- Update TOC
    - Change `Write docs > Doc blocks` from a menu to a page
    - Add `API > @storybook/blocks menu`
2023-02-21 22:38:18 -07:00

2.3 KiB

title
Doc blocks

Storybook offers a number of doc blocks to help document your components and other aspects of your project.

The blocks are most commonly used within Storybook's MDX documentation:

Screenshot of mdx content

{/* ButtonDocs.mdx */}
import { Meta, Primary, Controls, Story } from '@storybook/blocks';
import * as ButtonStories from './Button.stories';

<Meta of={ButtonStories} />

# Button

A button is ...

<Primary />

## Props

<Controls />

## Stories

### Primary

Button can be primary-colored

<Story of={ButtonStories.Primary} />

Button can be secondary-colored

<Story of={ButtonStories.Secondary} />

{/* ... */}

The blocks are also used in the default template for automatics docs:

Screenshot of automatic docs template

import { Title, Subtitle, Description, Primary, Controls, Stories } from '@storybook/blocks';

export const autoDocsTemplate = () => (
  <>
    <Title />
    <Subtitle />
    <Description />
    <Primary />
    <Controls />
    <Stories />
  </>
);

That template will show the primary (i.e. first) story for the component, a table documenting (and allowing you to control) the arg types of the primary story, and a list of all the stories in a condensed format.

Available blocks

For a description and API details of each block, see the API reference:

Make your own doc blocks

Storybook also provides a useOf hook to make it easier to create your own blocks that function in the same manner as the built-in blocks.