# Storybook README addon ![Storybook README addon](https://tuchk4.tinytake.com/media/6074cc?filename=1507031891423_03-10-2017-14-58-09.png&sub_type=thumbnail_preview&type=attachment&width=700&height=542&_felix_session_id=53f589ad3ebd6ae15ad9850b6bb20044&salt=MjAwMDAyNF82MzIxMzU2) This addon is compatible with: - Storybook for React ([React example storybook](packages/example-react)) - Storybook for Vue ([Vue example storybook](packages/example-vue)) [Live demo](https://tuchk4.github.io/storybook-readme) Features: - Does not affect on _story function_. So [Storybook Info](https://github.com/storybooks/storybook/tree/master/addons/info) works correctly now. - 100% markdown support - Code highlighting - Accept multiple README (useful for [hoc component](https://medium.com/@franleplant/react-higher-order-components-in-depth-cf9032ee6c3e) - add component's and original component's README) - Looks like Github's README - Supports `` tags for vue components ([example-vue/components/MyButton/MyButton.vue](https://github.com/tuchk4/storybook-readme/blob/master/packages/example-vue/components/MyButton/MyButton.vue)). Also it very useful because most projects and components already have _README.md_ files. Now it is easy to add them into your Storybook. Stories will be added with _.addWithInfo_ method if [Storybook Info Addon](https://github.com/storybooks/storybook/tree/master/addons/info) is installed. ### Install `npm install --save-dev storybook-readme` or `yarn add --dev storybook-readme` ### Webpack Configuration for React Storybook **There is no additional webpack configuration if using with `@storybooks/storybook@3.3.0`.** For lower versions use: ```js module.exports = { module: { rules: [ { test: /\.md$/, use: [ { loader: 'html-loader', }, { loader: 'markdown-loader', }, ], }, ], }, }; ``` ### Webpack Configuration for Vue Storybook Only if using [Single File Components](https://vuejs.org/v2/guide/single-file-components.html) and want to use `` tag at storybook documentation. ```js module.exports = storybookBaseConfig => { storybookBaseConfig.module.rules.push({ resourceQuery: /blockType=docs/, use: [ 'storybook-readme/env/vue/docs-loader', 'html-loader', 'markdown-loader', ], }); }; ``` ## Usage Register addon at _.storybook/addons.js_ ```js import 'storybook-readme/register'; ``` Then create your stories with the _withReadme_ or _withDocs_ API (use as story HOC or as Storybook Decorator). - _withDocs_ - Add README around the story component at the main panel. [Example withDocs](https://tuchk4.github.io/storybook-readme/?knob-alert=false&knob-success=false&knob-label=Hello%20Im%20Button&selectedKind=withDocs%2FAs%20Decorator&selectedStory=Button&full=0&down=1&left=1&panelRight=1&downPanel=storybooks%2Fstorybook-addon-knobs) - _withReadme_ - Add README to the storybook panels. [Example withReadme](https://tuchk4.github.io/storybook-readme/?knob-alert=false&knob-success=false&knob-label=Hello%20Im%20Button&selectedKind=withReadme%2F%20As%20Decorator&selectedStory=Button&full=0&down=1&left=1&panelRight=1&downPanel=REACT_STORYBOOK%2Freadme%2Fpanel) - _doc_ - Add README instead of component preview. [Example doc](https://tuchk4.github.io/storybook-readme/?knob-alert=false&knob-success=false&knob-label=Hello%20Im%20Button&selectedKind=Doc&selectedStory=Common&full=0&addons=1&stories=1&panelRight=1&addonPanel=storybooks%2Fstorybook-addon-knobs) It is possible to combine _withDocs_ and _withReadme_ - [Example combined APIs](https://tuchk4.github.io/storybook-readme/?knob-alert=false&knob-success=false&knob-label=Hello%20Im%20Button&selectedKind=withDocs%20and%20withReadme&selectedStory=Button&full=0&down=1&left=1&panelRight=1&downPanel=REACT_STORYBOOK%2Freadme%2Fpanel) ```js import ButtonReadme from '../components/button/README.md'; import { withReadme, withDocs } from 'storybook-readme'; // or import separately // import withReadme from 'storybook-readme/with-readme'; // import withDocs from 'storybook-readme/with-docs'; storiesOf('Button', module).add( 'Default', withReadme(ButtonReadme, () => (