Socket
Socket
Sign inDemoInstall

@storybook/addon-docs

Package Overview
Dependencies
338
Maintainers
11
Versions
1451
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @storybook/addon-docs

Superior documentation for your components


Version published
Maintainers
11
Created

Package description

What is @storybook/addon-docs?

The @storybook/addon-docs package is a Storybook addon that allows developers to write documentation alongside their stories. It uses MDX (Markdown with JSX) to let you document components in a rich, interactive way. It can generate documentation automatically based on your stories and supports a wide range of component frameworks.

What are @storybook/addon-docs's main functionalities?

MDX Documentation

Allows writing documentation using MDX, which can include both Markdown and JSX. You can define metadata, write narrative documentation, and showcase live examples and prop tables.

import { Meta, Story, ArgsTable, Canvas } from '@storybook/addon-docs/blocks';

<Meta title='MyComponent' />

# MyComponent

This is a **custom documentation** for `MyComponent`.

<Canvas>
  <Story name='Basic' args={{ label: 'Hello World' }}>
    {args => <MyComponent {...args} />}
  </Story>
</Canvas>

<ArgsTable story='Basic' />

Automatic Props Table

Generates a table of the component's props automatically. This table includes the prop names, types, default values, and descriptions if they are specified in the component's propTypes or TypeScript definitions.

import { Meta, Story, ArgsTable } from '@storybook/addon-docs/blocks';

<Meta title='MyComponent' />

<Story name='Basic'>
  <MyComponent />
</Story>

<ArgsTable of={MyComponent} />

Embedding Stories

Allows embedding live Storybook stories within the documentation. This provides an interactive example of the component in use.

import { Meta, Story } from '@storybook/addon-docs/blocks';

<Meta title='MyComponent' />

<Story name='Basic'>
  <MyComponent />
</Story>

Other packages similar to @storybook/addon-docs

Readme

Source

Storybook Docs

Living documentation for your components.

  • Sneak peak article
  • Technical preview guide

Installation

First add the package. Make sure that the versions for your @storybook/* packages match:

yarn add -D @storybooks/addon-docs

The add the following line to your .storybook/presets.js file:

module.exports = ['@storybook/addon-docs/react/preset'];

Finally, import your stories and MDX files in .storybook/config.js:

import { load } from '@storybook/react';

// standard configuration here
// ...

// wherever your story files are located
load(require.context('../src', true, /\.stories\.js$/), module);
load(require.context('../src', true, /\.stories\.mdx$/), module);

Manual configuration

Docs uses Storybook presets as a configuration shortcut. To configure "the long way", first register the addon in .storybook/addons.js:

import '@storybook/addon-docs/register';

Then configure Storybook's webpack loader to understand MDX files in .storybook/webpack.config.js:

const createCompiler = require('@storybook/addon-docs/mdx-compiler-plugin');

module.exports = async ({ config }) => {
  config.module.rules.push({
    test: /\.mdx$/,
    use: [
      { loader: 'babel-loader' },
      {
        loader: '@mdx-js/loader',
        options: {
          compilers: [createCompiler({})],
        },
      },
    ],
  });
  return config;
};

Keywords

FAQs

Last updated on 15 May 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc