UNPKG

2.31 kBMarkdownView Raw
1# Storybook Addon Notes
2
3Storybook Addon Notes allows you to write notes (text or HTML) for your stories in [Storybook](https://storybook.js.org).
4
5[Framework Support](https://github.com/storybookjs/storybook/blob/master/ADDONS_SUPPORT.md)
6
7![Storybook Addon Notes Demo](docs/demo.png)
8
9## Getting Started
10
11**NOTE: Documentation on `next` branch is for alpha version, stable release is on [master](https://github.com/storybookjs/storybook/tree/master/addons/)**
12
13```sh
14yarn add -D @storybook/addon-notes
15```
16
17within `.storybook/main.js`:
18
19```js
20module.exports = {
21 addons: ['@storybook/addon-notes/register']
22}
23```
24
25Alternatively register the notes addon into a panel. Choose only one, not both.
26
27```js
28module.exports = {
29 addons: ['@storybook/addon-notes/register-panel']
30}
31```
32
33Now, you can use the `notes` parameter to add a note to each story.
34
35
36```js
37import Component from './Component';
38
39export default {
40 title: 'Component',
41 parameters: {
42 notes: 'some documentation here',
43 },
44};
45```
46
47### Upgrading to CSF Format
48
49Add `notes` to the `parameters` object:
50
51```js
52export default {
53 parameters: {
54 notes: 'My notes',
55 }
56}
57```
58
59## Using Markdown
60
61Using Markdown in your notes is supported, Storybook will load Markdown as raw by default.
62
63```js
64import Component from './Component';
65import markdown from './someMarkdownText.md';
66
67export default {
68 title: 'Component',
69};
70
71export const withMarkdown = () => <Component />;
72withmarkdown.story = {
73 parameters: {
74 notes: { markdown },
75 }
76};
77```
78
79## Giphy
80
81When using Markdown, you can also embed gifs from Giphy into your Markdown. Currently, the value `cheese` of the query prop is used to search and return the first result returned by Giphy.
82
83```md
84# Title
85
86<Giphy query='cheese' />
87```
88
89## Multiple Notes Sections
90
91If you need to display different notes for different consumers of your storybook (e.g design, developers), you can configure multiple notes pages. The following will render a tab with unique notes for both `Introduction` and `Design`.
92
93```js
94import { storiesOf } from '@storybook/react';
95import Component from './Component';
96
97import intro from './intro.md';
98import design from './design.md';
99
100export default {
101 title: 'Component',
102 parameters: {
103 notes: { Introduction: intro, 'Design Notes': design },
104 },
105};
106```