Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable 'Docs' tab in storybook?

Tags:

storybook

How do i disable the 'docs' (addons-docs) tab on a per story basis?

I've tried adding the key values below to a story, but nothing seems to work.

parameters: {
  docs: { disable: true, hidden: true }
},

I'm running Storybook 5.3.8.

like image 511
Jele Avatar asked Jan 27 '20 14:01

Jele


People also ask

How do I hide the tab in storybook?

edited. It is possible to reach the above example story's Docs tab by selecting the Docs tab in a different story then navigating to the above example. Click on any story with a Docs tab. Then, click on the story where the Docs tab should be hidden .

Is Storybook good for documentation?

Storybook is a playground for UI development. It's a great tool to help designers, project managers, and developers understand and visualize components in the system with clear documentation and usage examples.

What is addon in storybook?

Addons extend Storybook with features and integrations that are not built into the core. Most Storybook features are implemented as addons. For instance: documentation, accessibility testing, interactive controls, among others. The addon API makes it easy for you to configure and customize Storybook in new ways.


4 Answers

This will hide docs panel and show canvas only:

  parameters: {
    previewTabs: {
      'storybook/docs/panel': {
        hidden: true,
      },
    },
  },

Tabs container will be hidden, if you have only one tab

like image 102
Do Async Avatar answered Oct 06 '22 03:10

Do Async


I managed to do it with the v6.0.0-alpha.28 (@storybook/*@next) with the new parameters:

  previewTabs: {
    docs: { hidden: true },
  }

I've added the default config on preview.js:

addParameters({
  previewTabs: {
    docs: {
      hidden: false
    },
    canvas: {
      title: 'Story',
      hidden: false,
    },
  },
})

and also repositioned the Docs to be the first tab on manager.js:

import { addons } from '@storybook/addons';

addons.setConfig({
  previewTabs: {
    'storybook/docs/panel': { index: -1 },
  },
});

Hope it works on the long term :) Enjoy!

like image 25
Mateo Tibaquira Avatar answered Oct 06 '22 03:10

Mateo Tibaquira


Inside your MyStory.stories.j[t]sx file

To hide the "Docs" tab:

export default {
    title: 'YourTitle',
    parameters: {
        previewTabs: {
            'storybook/docs/panel': { hidden: true }
        },
        viewMode: 'canvas',
    }
};

To hide the "Canvas" tab:

export default {
    title: 'YourTitle',
    parameters: {
        previewTabs: {
            canvas: { hidden: true},
        },
        viewMode: 'docs',
    }
};

The viewMode: 'docs/canvas' it's necessary to set the default tab in that view, otherwise storybook will show the last tab opened in the previous view.

like image 26
Juanma Menendez Avatar answered Oct 06 '22 04:10

Juanma Menendez


Old Answers give you the technique to hide the docs but if someone will change the URL from story to docs, it will show the results, so I am giving you the way to perfectly remove the docs tab.

1st Method

If you added the @storybook/addon-docs package to your package.json and added it into .storybook/main.js ( addon array ) then remove it and restart your storybook webpack server.

2nd Method

In the latest version of the storybook, it recommends to add an essentials addon package coming from storybook that contains multiple addons such as actions, backgrounds, controls, docs, viewport, toolbars.

So if you installed that package and added it into the .storybook/main.js addon array then you disable it with the below code.

Replace your code from

module.exports = {
  addons: [
    ...,
    '@storybook/addon-essentials',
  ],
};

TO

module.exports = {
  addons: [
    ...,
    {
      name: '@storybook/addon-essentials',
      options: {
        docs: false,
      },
    },
  ],
};
like image 33
Nisharg Shah Avatar answered Oct 06 '22 02:10

Nisharg Shah