Join live session: Thu, 11am EDT, Storybook 9 release & AMA
Docs
Storybook Docs

Features and behavior

To control the layout of Storybook’s UI you can use addons.setConfig in your .storybook/manager.js:

.storybook/manager.ts
import { addons, type State } from 'storybook/manager-api';
 
addons.setConfig({
  navSize: 300,
  bottomPanelHeight: 300,
  rightPanelWidth: 300,
  panelPosition: 'bottom',
  enableShortcuts: true,
  showToolbar: true,
  theme: undefined,
  selectedPanel: undefined,
  initialActive: 'sidebar',
  layoutCustomisations: {
    showSidebar(state: State, defaultValue: boolean) {
      return state.storyId === 'landing' ? false : defaultValue;
    },
    showToolbar(state: State, defaultValue: boolean) {
      return state.viewMode === 'docs' ? false : defaultValue;
    },
  },
  sidebar: {
    showRoots: false,
    collapsedRoots: ['other'],
  },
  toolbar: {
    title: { hidden: false },
    zoom: { hidden: false },
    eject: { hidden: false },
    copy: { hidden: false },
    fullscreen: { hidden: false },
  },
});

The following table details how to use the API values:

NameTypeDescriptionExample Value
navSizeNumber (pixels)The size of the sidebar that shows a list of stories300
bottomPanelHeightNumber (pixels)The size of the addon panel when in the bottom position200
rightPanelWidthNumber (pixels)The size of the addon panel when in the right position200
panelPositionStringWhere to show the addon panel'bottom' or 'right'
enableShortcutsBooleanEnable/disable shortcutstrue
showToolbarBooleanShow/hide tool bartrue
themeObjectStorybook Theme, see next sectionundefined
selectedPanelStringId to select an addon panel'storybook/actions/panel'
initialActiveStringSelect the default active tab on Mobile'sidebar' or 'canvas' or 'addons'
layoutCustomisationsObjectLayout customisation options, see below{ showSidebar: ({ viewMode }, defaultValue) => viewMode === 'docs' ? false : defaultValue }`
sidebarObjectSidebar options, see below{ showRoots: false }
toolbarObjectModify the tools in the toolbar using the addon id{ fullscreen: { hidden: false } }

The following options are configurable under the sidebar namespace:

NameTypeDescriptionExample Value
showRootsBooleanDisplay the top-level nodes as a "root" in the sidebarfalse
collapsedRootsArraySet of root node IDs to visually collapse by default['misc', 'other']
renderLabelFunctionCreate a custom label for tree nodes; must return a ReactNode(item, api) => <abbr title="...">{item.name}</abbr>

The following options are configurable under the toolbar namespace:

NameTypeDescriptionExample Value
[id]StringToggle visibility for a specific toolbar item (e.g. title, zoom){ hidden: false }

The following options are configurable under the layoutCustomisations namespace:

NameTypeDescriptionExample Value
showSidebarFunctionToggle visibility for the sidebar({ storyId }, defaultValue) => storyId === 'landing' ? false : defaultValue
showToolbarFunctionToggle visibility for the toolbar({ viewMode }, defaultValue) => viewMode === 'docs' ? false : defaultValue

The showSidebar and showToolbar functions let you hide parts of the UI that are essential to Storybook's functionality. If misused, they can make navigation impossible. When hiding the sidebar, ensure the displayed page provides an alternative means of navigation.

Customize the UI

Storybook's UI is highly customizable. Its API and configuration options, available via the showSidebar and showToolbar functions, allow you to control how the sidebar and toolbar elements are displayed. Both functions will enable you to include some default behavior and can be overridden to customize the UI to your needs.

Override sidebar visibility

The sidebar, present on the left of the screen, contains the search function and navigation menu. Users may show or hide it with a keyboard shortcut. If you want to force the sidebar to be visible or hidden in certain places, you can define a showSidebar function in layoutCustomisations. Below are the available parameters passed to this function and an overview of how to use them.

NameTypeDescriptionExample Value
pathStringPath to the page being displayed'/story/components-button--default'
viewModeStringWhether the current page is a story or docs'docs' or 'story'
singleStoryBooleanWhether the current page is the only story for a componenttrue or false
storyIdStringThe id of the current story or docs page'blocks-blocks-unstyled--docs'
layoutObjectThe current layout statesee below
layout.isFullscreenBooleanWhether the preview canvas is in fullscreen modetrue or false
layout.panelPositionStringWhether the panel is shown below or on the side of the preview'bottom' or 'right'
layout.showNavBooleanThe setting for whether the end user wants to see the sidebartrue or false
layout.showPanelBooleanThe setting for whether the end user wants to see the paneltrue or false
layout.showSidebarBooleanThe setting for whether the end user wants to see the sidebartrue or false
./storybook/manager.ts
import { addons, type State } from 'storybook/manager-api';
 
addons.setConfig({
  layoutCustomisations: {
    // Hide the sidebar on the landing page, which has its own nav links to other pages.
    showSidebar(state: State, defaultValue: boolean) {
      if (state.storyId === 'landing' && state.viewMode === 'docs') {
        return false;
      }
 
      return defaultValue;
    },
  },
});

If you're hiding the sidebar through showSidebar, ensure the displayed page provides an alternative means of navigation.

Configure the toolbar

By default, Storybook displays a toolbar at the top of the UI, allowing you to access menus from addons (e.g., viewport, background), or custom defined menus. However, if you want to customize the toolbar's behavior, you can use the showToolbar function. Listed below are the available options and an overview of how to use them.

NameTypeDescriptionExample Value
pathStringPath to the page being displayed'/story/components-button--default'
viewModeStringWhether the current page is a story or docs'docs' or 'story'
singleStoryBooleanWhether the current page is the only story for a componenttrue or false
storyIdStringThe id of the current story or docs page'blocks-blocks-unstyled--docs'
layoutObjectThe current layout statesee below
layout.isFullscreenBooleanWhether the preview canvas is in fullscreen modetrue or false
layout.panelPositionStringWhether the panel is shown below or on the side of the preview'bottom' or 'right'
layout.showNavBooleanThe setting for whether the end user wants to see the sidebartrue or false
layout.showPanelBooleanThe setting for whether the end user wants to see the paneltrue or false
layout.showToolbarBooleanThe setting for whether the end user wants to see the toolbartrue or false
./storybook/manager.ts
import { addons, type State } from 'storybook/manager-api';
 
addons.setConfig({
  layoutCustomisations: {
    // Always hide the toolbar on docs pages, and respect user preferences elsewhere.
    showToolbar(state: State, defaultValue: boolean) {
      if (state.viewMode === 'docs') {
        return false;
      }
 
      return defaultValue;
    },
  },
});

Configuring through URL parameters

You can use URL parameters to configure some of the available features:

Config optionQuery paramSupported values
enableShortcutsshortcutsfalse
--- (fullscreen)fulltrue, false
--- (show sidebar)navtrue, false
--- (show panel)panelfalse, 'right', 'bottom'
selectedPaneladdonPanelAny panel ID
showTabstabstrue
---instrumentfalse, true