2017-05-17 00:21:36 +02:00
# Storybook Options Addon
2017-05-26 11:21:46 +02:00
2017-10-23 16:01:20 +02:00
[](https://circleci.com/gh/storybooks/storybook)
2017-05-17 00:21:36 +02:00
[](https://www.codefactor.io/repository/github/storybooks/storybook)
[](https://snyk.io/test/github/storybooks/storybook/8f36abfd6697e58cd76df3526b52e4b9dc894847)
2017-10-23 16:01:20 +02:00
[](https://bettercodehub.com/results/storybooks/storybook) [](https://codecov.io/gh/storybooks/storybook)
2017-12-22 18:06:27 +01:00
[](https://now-examples-slackin-rrirkqohko.now.sh/)
2017-10-23 16:01:20 +02:00
[](#backers ) [](#sponsors )
2017-04-10 23:14:32 +02:00
2017-10-23 16:01:20 +02:00
* * *
The Options addon can be used to (re-)configure the [Storybook ](https://storybook.js.org ) UI at runtime.
2017-04-10 23:14:32 +02:00
2018-02-21 16:17:02 +02:00
[Framework Support ](https://github.com/storybooks/storybook/blob/master/ADDONS_SUPPORT.md )
2017-05-17 00:21:36 +02:00

2017-04-10 23:14:32 +02:00
## Getting Started
First, install the addon
2017-05-17 00:21:36 +02:00
```sh
2017-05-14 10:33:51 +02:00
npm install -D @storybook/addon -options
2017-04-10 23:14:32 +02:00
```
Add this line to your `addons.js` file (create this file inside your storybook config directory if needed).
```js
2017-05-14 10:33:51 +02:00
import '@storybook/addon -options/register';
2017-04-10 23:14:32 +02:00
```
Import and use the `setOptions` function in your config.js file.
```js
2017-05-14 10:33:51 +02:00
import * as storybook from '@storybook/react ';
import { setOptions } from '@storybook/addon -options';
2017-04-10 23:14:32 +02:00
2017-08-01 11:39:40 -04:00
// Option defaults:
2017-04-10 23:14:32 +02:00
setOptions({
2017-08-01 11:39:40 -04:00
/**
2017-08-01 13:24:59 -04:00
* name to display in the top left corner
2017-08-01 11:39:40 -04:00
* @type {String}
*/
name: 'Storybook',
/**
2017-08-01 13:24:59 -04:00
* URL for name in top left corner to link to
2017-08-01 11:39:40 -04:00
* @type {String}
*/
url: '#',
/**
* show story component as full screen
* @type {Boolean}
*/
2017-04-10 23:14:32 +02:00
goFullScreen: false,
2017-08-01 11:39:40 -04:00
/**
2017-08-31 02:08:32 +03:00
* display panel that shows a list of stories
2017-08-01 11:39:40 -04:00
* @type {Boolean}
*/
2017-08-31 02:08:32 +03:00
showStoriesPanel: true,
2017-08-01 11:39:40 -04:00
/**
2017-08-31 02:08:32 +03:00
* display panel that shows addon configurations
2017-08-01 11:39:40 -04:00
* @type {Boolean}
*/
2017-08-31 02:08:32 +03:00
showAddonPanel: true,
2017-08-01 11:39:40 -04:00
/**
2017-08-01 13:24:59 -04:00
* display floating search box to search through stories
2017-08-01 11:39:40 -04:00
* @type {Boolean}
*/
2017-08-01 13:24:59 -04:00
showSearchBox: false,
2017-08-01 11:39:40 -04:00
/**
2017-08-31 02:08:32 +03:00
* show addon panel as a vertical panel on the right
2017-08-01 11:39:40 -04:00
* @type {Boolean}
*/
2017-08-31 02:08:32 +03:00
addonPanelInRight: false,
2017-08-01 11:39:40 -04:00
/**
* sorts stories
* @type {Boolean}
*/
2017-04-10 23:14:32 +02:00
sortStoriesByKind: false,
2017-08-01 11:39:40 -04:00
/**
* regex for finding the hierarchy separator
* @example:
* null - turn off hierarchy
* /\// - split by `/`
* /\./ - split by `.`
* /\/|\./ - split by `/` or `.`
* @type {Regex}
*/
hierarchySeparator: null,
2017-12-09 12:37:32 +01:00
/**
* regex for finding the hierarchy root separator
* @example:
* null - turn off mulitple hierarchy roots
* /\|/ - split by `|`
* @type {Regex}
*/
2017-12-09 15:51:38 +01:00
hierarchyRootSeparator: null,
2017-08-04 19:54:08 +02:00
/**
* sidebar tree animations
* @type {Boolean}
*/
sidebarAnimations: true,
2017-08-11 22:21:59 +03:00
/**
* id to select an addon panel
* @type {String}
*/
2017-08-31 02:08:32 +03:00
selectedAddonPanel: undefined, // The order of addons in the "Addon panel" is the same as you import them in 'addons.js'. The first panel will be opened by default as you run Storybook
2018-03-19 20:50:58 +05:30
/**
* enable/disable shortcuts
* @type {Boolean}
*/
2018-03-19 20:55:01 +05:30
enableShortcuts: false, // true by default
2017-04-10 23:14:32 +02:00
});
storybook.configure(() => require('./stories'), module);
```
2017-10-29 18:56:52 -04:00
It is also possible to call `setOptions()` inside individual stories. Note that this will bring impact story render performance significantly.