{"id":13667808,"url":"https://github.com/tuchk4/storybook-readme","last_synced_at":"2025-05-15T09:05:47.218Z","repository":{"id":11941728,"uuid":"70843320","full_name":"tuchk4/storybook-readme","owner":"tuchk4","description":"React Storybook addon to render README files in github style","archived":false,"fork":false,"pushed_at":"2022-12-13T13:30:48.000Z","size":5855,"stargazers_count":543,"open_issues_count":95,"forks_count":247,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-05-06T15:19:28.711Z","etag":null,"topics":["react","react-storybook","react-storybook-addons","readme","storybook"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tuchk4.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["sdoomz","tuchk4"],"patreon":null,"open_collective":null,"ko_fi":"tuchk4","tidelift":null,"custom":null}},"created_at":"2016-10-13T20:01:09.000Z","updated_at":"2025-05-04T12:08:04.000Z","dependencies_parsed_at":"2023-01-13T16:44:01.641Z","dependency_job_id":null,"html_url":"https://github.com/tuchk4/storybook-readme","commit_stats":null,"previous_names":[],"tags_count":52,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuchk4%2Fstorybook-readme","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuchk4%2Fstorybook-readme/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuchk4%2Fstorybook-readme/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuchk4%2Fstorybook-readme/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tuchk4","download_url":"https://codeload.github.com/tuchk4/storybook-readme/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254310513,"owners_count":22049468,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["react","react-storybook","react-storybook-addons","readme","storybook"],"created_at":"2024-08-02T07:00:50.647Z","updated_at":"2025-05-15T09:05:47.202Z","avatar_url":"https://github.com/tuchk4.png","language":"JavaScript","funding_links":["https://github.com/sponsors/sdoomz","https://github.com/sponsors/tuchk4","https://ko-fi.com/tuchk4"],"categories":["JavaScript","Community Addons","📦 Legacy \u0026 Inactive Projects","Design System Tools"],"sub_categories":["Components"],"readme":"# Storybook README addon\n\nNOTE: This README is only for version `^5.0.0`. For older versions [README_V4.md](./README_V4.md)\n\nAll previous api should work correctly at `^5.0.0` and above. **But vue users will need to change their import path, as vue commands have been moved to their own folder.**\n\n---\n\n![Storybook README addon](https://user-images.githubusercontent.com/5140611/54478027-86d38400-4816-11e9-96a0-aecef64e3ea7.png)\n\nThis addon is compatible with:\n\n- [React Storybook](https://storybook.js.org/docs/guides/guide-react/) ([React example storybook](packages/example-react))\n- [Vue Storybook](https://storybook.js.org/docs/guides/guide-vue/) ([Vue example storybook](packages/example-vue))\n- Particularly [HTML Storybook](https://storybook.js.org/docs/guides/guide-html/)\n\n[Live demo](https://tuchk4.github.io/storybook-readme)\n\nFeatures:\n\n- Automatically generate props table (only for React)\n- 100% markdown support\n- Code highlighting\n- Possible to add docs to addons panel or around the story\n- 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)\n- Looks like Github's README\n- Supports `\u003cdocs/\u003e` 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)).\n\nAlso it very useful because most projects and components already have _README.md_ files. Now it is easy to add them into your Storybook.\n\nStories will be added with _.addWithInfo_ method if [Storybook Info Addon](https://github.com/storybooks/storybook/tree/master/addons/info) is installed.\n\n## Install\n\n`npm install --save-dev storybook-readme`\n\nor\n\n`yarn add --dev storybook-readme`\n\n#### Webpack Configuration for React Storybook\n\nNothing to do :)\n\nBut if you are using Typescript with React you need to add [markdown-loader](https://www.npmjs.com/package/markdown-loader) in your webpack config\n\n```js\n{\n  test: /\\.md$/,\n  use: [\n    {\n      loader: 'markdown-loader',\n    }\n  ]\n}\n```\n\n#### Webpack Configuration for Vue Storybook\n\nOnly for [Single File Components](https://vuejs.org/v2/guide/single-file-components.html) with `\u003cdocs\u003e` tag used for documentation.\n\n```js\nmodule.exports = storybookBaseConfig =\u003e {\n  storybookBaseConfig.module.rules.push({\n    resourceQuery: /blockType=docs/,\n    use: ['storybook-readme/vue/docs-loader', 'html-loader', 'markdown-loader'],\n  });\n};\n```\n\nDefine `\u003cdocs\u003e` tag inside vue module:\n\n```vue\n\u003cdocs\u003e\nDocs inside vue module \n\u003c/docs\u003e\n\n\u003ctemplate\u003e\n  \u003cbutton class=\"button\"\u003e\n    \u003cslot\u003e\u003c/slot\u003e\n  \u003c/button\u003e\n\u003c/template\u003e\n```\n\nUse it to define docs at story:\n\n```js\nimport MyButton from '../components/MyButton/MyButton.vue';\n\nstoriesOf('Vue \u003cdocs\u003e', module).addParameters({\n  readme: {\n    content: MyButton.__docs,\n  },\n});\n```\n\n## Setup\n\n#### Register addon at _.storybook/addons.js_\n\n```js\nimport 'storybook-readme/register';\n```\n\nNOTE: It is possible to set addon's panel title\n\n```js\nimport registerWithPanelTitle from 'storybook-readme/registerWithPanelTitle';\n\nregisterWithPanelTitle('Docs');\n```\n\n#### Add decorator at _.storybook/config.js_\n\n```js\nimport { addDecorator, configure } from '@storybook/react';\nimport { addReadme } from 'storybook-readme';\n\n// for Vue storybook\nimport { addReadme } from 'storybook-readme/vue'; // \u003c---- vue subpackage\n\n// for HTML storybook\nimport { addReadme } from 'storybook-readme/html'; // \u003c---- html subpackage\n\naddDecorator(addReadme);\n\nfunction loadStories() {\n  require('../stories/index.js');\n}\n\nconfigure(loadStories, module);\n```\n\n\u003e NOTE: for html storybook only sidebar docs are available.\n\n## Usage\n\nHope it is very simple.\n\n```js\nimport React from 'react';\nimport { storiesOf } from '@storybook/react';\n\nimport Button from '../components/Button';\nimport ButtonReadme from '../components/Button/README.md';\n\nstoriesOf('Buttons', module)\n  .addDecorator(withKnobs)\n  .addParameters({\n    readme: {\n      // Show readme before story\n      content: ButtonReadme,\n      // Show readme at the addons panel\n      sidebar: ButtonReadme,\n    },\n  })\n  .add('Button', () =\u003e \u003cButton /\u003e);\n```\n\nIt is possible to override docs for story\n\n```js\nimport React from 'react';\nimport { storiesOf } from '@storybook/react';\n\nimport Button from '../components/Button';\nimport ButtonReadme from '../components/Button/README.md';\n\nstoriesOf('Buttons', module)\n  .addDecorator(withKnobs)\n  .addParameters({\n    readme: {\n      content: ButtonReadme,\n      sidebar: ButtonReadme,\n    },\n  })\n  .add('Button', () =\u003e \u003cButton /\u003e)\n  .add('Button', () =\u003e \u003cButton /\u003e)\n  .add('Button', () =\u003e \u003cButton /\u003e, {\n    readme: {\n      // override docs\n      content: CustomButtonReadme,\n      sidebar: CustomButtonReadme,\n    },\n  });\n```\n\n## Full list of options\n\nWill be applied for series of stories.\n\n```js\n.addParameters({\n    readme: {\n      /**\n       * Accepts string (markdown) or array of strings\n       * string | Array\u003cstring\u003e\n       */\n      content: Readme,\n\n      /**\n       * Accepts string (markdown) or array of strings\n       * string | Array\u003cstring\u003e\n       */\n      sidebar: Readme,\n\n      /**\n       * Enable / disable code highlighting for sidebar. true by default\n       */\n      highlightSidebar: true,\n\n      /**\n       * Enable / disable code highlighting for content. true by default\n       */\n      highlightContent: true,\n\n      /**\n       * Override theme values\n       *\n       * All theme values https://github.com/tuchk4/storybook-readme/blob/master/packages/storybook-readme/src/styles/githubMarkdownCss.js#L436\n\n       */\n      theme: {},\n\n      /**\n       * Prism code theme\n       * Full list of theme https://github.com/PrismJS/prism-themes\n       * To be used with storybook-readme, naming of the code theme should be used in one of these styles. https://github.com/tuchk4/storybook-readme/tree/master/packages/storybook-readme/src/styles/prismCodeThemes\n       */\n      codeTheme: 'github',\n\n      /**\n       * You can include prop tables locally here. See `propTables` example\n       * for more information\n       */\n      includePropTables: [YourImportedReactComponent],\n\n      /**\n       * Wrapper for story. Usually used to set some styles\n       * NOTE: will be applied only for content docs (docs around the story)\n       *\n       * React: React.ReactNode\n       * Vue: Vue component\n       */\n      StoryPreview: ({ children}) =\u003e \u003cdiv\u003e{children}\u003c/div\u003e\n\n      /**\n       * Wrapper for header docs. Usually used to set some styles\n       * NOTE: will be applied only for content docs (docs around the story)\n       *\n       * React: React.ReactNode\n       * Vue: Vue component\n       */\n      HeaderPreview: ({ children}) =\u003e \u003cdiv\u003e{children}\u003c/div\u003e\n\n      /**\n       * Wrapper for footer docs. Usually used to set some styles\n       * NOTE: will be applied only for content docs (docs around the story)\n       *\n       * React: React.ReactNode\n       * Vue: Vue component\n       */\n      FooterPreview: ({ children}) =\u003e \u003cdiv\u003e{children}\u003c/div\u003e\n\n      /**\n       * Wrapper for content and sidebar docs. Usually used to set some styles\n       * NOTE: will be applied only for content docs (docs around the story)\n       *\n       * React: React.ReactNode\n       * Vue: Vue component\n       */\n      DocPreview: ({ children}) =\u003e \u003cdiv\u003e{children}\u003c/div\u003e\n    },\n  })\n```\n\n## Global configuration\n\nWill be applied for all stories.\nNOTE: that `global configuration` is applied only for content docs (docs around the story).\n\n```js\nimport { addParameters } from '@storybook/react'; // or @storybook/vue for vuejs\nimport { configureReadme } from 'storybook-readme';\n\nconfigureReadme({\n  /**\n   * Wrapper for story. Usually used to set some styles\n   * React: React.ReactNode\n   * Vue: Vue component\n   */\n  StoryPreview: ({ children }) =\u003e \u003cdiv\u003e{children}\u003c/div\u003e,\n\n  /**\n   * Wrapper for content and sidebar docs. Usually used to set some styles\n   * React: React.ReactNode\n   * Vue: Vue component\n   */\n  DocPreview: ({ children }) =\u003e (\n    \u003cdiv style={{ background: '#000' }}\u003e {children}\u003c/div\u003e\n  ),\n\n  /**\n   * Wrapper for header docs. Usually used to set some styles\n   * React: React.ReactNode\n   * Vue: Vue component\n   */\n  HeaderPreview: ({ children }) =\u003e (\n    \u003cdiv style={{ background: 'red' }}\u003e{children}\u003c/div\u003e\n  ),\n\n  /**\n   * Wrapper for footer docs. Usually used to set some styles\n   * React: React.ReactNode\n   * Vue: Vue component\n   */\n  FooterPreview: ({ children }) =\u003e \u003cdiv\u003e{children}\u003c/div\u003e,\n\n  /**\n   * Header docs in markdown format\n   */\n  header: '',\n\n  /**\n   * Footer docs in markdown format\n   */\n  footer: '',\n});\n\naddParameters({\n  readme: {\n    // You can set a code theme globally.\n    codeTheme: 'github',\n\n    // You can exclude prop tables globally here. See `propTables` example\n    // for more information\n    excludePropTables: [YourImportedReactComponent],\n  },\n});\n```\n\n## Readme placeholders\n\n- `\u003c!-- STORY --\u003e` placeholder for story\n- `\u003c!-- SOURCE --\u003e` placeholder for story source\n- `\u003c!-- STORY_SOURCE --\u003e` placeholder for story source\n- `\u003c!-- PROPS --\u003e` placeholder for props table. There are some issue with props parsing. Clarification [issue#137](https://github.com/tuchk4/storybook-readme/issues/137#issuecomment-481307652)\n- `\u003c!-- STORY HIDE START --\u003e`, `\u003c!-- STORY HIDE END --\u003e` content enclosed by the tags won't be shown in stories\n\n```md\nButton variants could be imported separately.\n\n\\`\\`\\`js import { OutlinedButton, ContainedButton, TextButton } from 'Button'; \\`\\`\\`\n\n\u003c!-- PROPS --\u003e\n\nExample:\n\n\u003c!-- STORY --\u003e\n\u003c!-- SOURCE --\u003e\n\n\u003c!-- STORY HIDE START --\u003e\n\ncontent here won't be shown in stories\n\n\u003c!-- STORY HIDE END --\u003e\n\nSome docs after story\n```\n\n## Emoji\n\nUse shortcodes between colon to insert emoji into the docs. For example\n\nHere is rocket \u0026#58;rocket\u0026#58;\n\nHere is rocket :rocket:\n\nList of all shortcodes could be found at [Emojipedia](https://emojipedia.org) or at [Gist/rxaviers](https://gist.github.com/rxaviers/7360908)\n\n- :rocket:\n- :grinning:\n- :monkey:\n\nFeel free to suggest new features or report bugs :)\n\n## Api from v4.\n\nFull docs for previous api are at [README_V4.md](./README_V4.md)\n\nTL;DR:\n\n\u003e Accepts README or array of README in markdown format. Multiple README is useful when you develop higher order components and want to add multiple READMEs along with the original component docs.\n\n#### withReadme\n\nRenders README at the addons panel.\n\n```js\nimport { withReadme } from 'storybook-readme';\nimport withReadme from 'storybook-readme/with-readme';\n\n// as HigherOrder Component\nstoriesOf('Button', module).add(\n  'Default',\n  withReadme(ButtonReadme, () =\u003e \u003cButton /\u003e),\n);\n// as Decorator\nstoriesOf('Button', module)\n  .addDecorator(withReadme(ButtonReadme))\n  .add('Default', () =\u003e \u003cButton /\u003e);\n```\n\n#### withDocs\n\nRenders README around the story.\n\n```js\nimport { withDocs } from 'storybook-readme';\nimport withDocs from 'storybook-readme/with-docs';\n\n// as HigherOrder Component\nstoriesOf('Button', module).add(\n  'Default',\n  withDocs(ButtonReadme, () =\u003e \u003cButton /\u003e),\n);\n// as Decorator\nstoriesOf('Button', module)\n  .addDecorator(withDocs(ButtonReadme))\n  .add('Default', () =\u003e \u003cButton /\u003e);\n```\n\n#### doc\n\nRenders README in main frame without story.\n\n```js\nimport { doc } from 'storybook-readme';\n\nstoriesOf('Button', module).add('Default', () =\u003e doc(ButtonReadme));\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftuchk4%2Fstorybook-readme","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftuchk4%2Fstorybook-readme","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftuchk4%2Fstorybook-readme/lists"}