Options Parameter

Storybook UI is configurable using an options API that allows you to tweak its appearance globally and for each story.

NOTE: If you’ve used older versions of Storybook this is formerly addon-options, which has been deprecated.

Global options

Import and use addParameters with the options key in your config.js file.

  1. import { addParameters, configure } from '@storybook/react';
  2. // Option defaults:
  3. addParameters({
  4. options: {
  5. /**
  6. * show story component as full screen
  7. * @type {Boolean}
  8. */
  9. isFullscreen: false,
  10. /**
  11. * display panel that shows a list of stories
  12. * @type {Boolean}
  13. */
  14. showNav: true,
  15. /**
  16. * display panel that shows addon configurations
  17. * @type {Boolean}
  18. */
  19. showPanel: true,
  20. /**
  21. * where to show the addon panel
  22. * @type {('bottom'|'right')}
  23. */
  24. panelPosition: 'bottom',
  25. /**
  26. * regex for finding the hierarchy separator
  27. * @example:
  28. * null - turn off hierarchy
  29. * /\// - split by `/`
  30. * /\./ - split by `.`
  31. * /\/|\./ - split by `/` or `.`
  32. * @type {Regex}
  33. */
  34. hierarchySeparator: /\/|\./,
  35. /**
  36. * regex for finding the hierarchy root separator
  37. * @example:
  38. * null - turn off multiple hierarchy roots
  39. * /\|/ - split by `|`
  40. * @type {Regex}
  41. */
  42. hierarchyRootSeparator: /\|/,
  43. /**
  44. * sidebar tree animations
  45. * @type {Boolean}
  46. */
  47. sidebarAnimations: true,
  48. /**
  49. * enable/disable shortcuts
  50. * @type {Boolean}
  51. */
  52. enableShortcuts: true,
  53. /**
  54. * show/hide tool bar
  55. * @type {Boolean}
  56. */
  57. isToolshown: true,
  58. /**
  59. * theme storybook, see link below
  60. */
  61. theme: undefined,
  62. /**
  63. * function to sort stories in the tree view
  64. * common use is alphabetical `(a, b) => a[1].id.localeCompare(b[1].id)`
  65. * if left undefined, then the order in which the stories are imported will
  66. * be the order they display
  67. * @type {Function}
  68. */
  69. storySort: undefined,
  70. },
  71. });

For more information on configuring the theme, see theming.

Per-story options

The options-addon accepts story parameters on the options key:

  1. import { storiesOf } from '@storybook/react';
  2. import MyComponent from './my-component';
  3. storiesOf('Addons|Custom options', module)
  4. // If you want to set the option for all stories in of this kind
  5. .addParameters({ options: { panelPosition: 'bottom' } })
  6. .add(
  7. 'Story for MyComponent',
  8. () => <MyComponent />,
  9. // If you want to set the options for a specific story
  10. { options: { panelPosition: 'right' } }
  11. );