Package Exports
- react-storybook-addon-props-combinations
- react-storybook-addon-props-combinations/dist/utils
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-storybook-addon-props-combinations) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Props Combinations addon for React Storybook
Given possible values for each prop, renders your component with all combinations of prop values. Useful for finding edge cases or just seeing all component states at once.
Live demo
Installation
Install it:
npm i -D react-storybook-addon-props-combinations
Then set the addon in your .storybook/config.js
:
import { configure, setAddon } from '@kadira/storybook'
import withPropsCombinations, { setDefaults } from 'react-storybook-addon-props-combinations'
setAddon(withPropsCombinations)
setDefaults({
// overwrite global defaults here
})
configure(() => {
// ...
}, module)
Basic usage
import React from 'react';
import { storiesOf, action } from '@kadira/storybook';
import YourComponent from './somewhere'
storiesOf('Basics', module)
.addWithPropsCombinations(
'Standard usage',
// provide your component
YourComponent,
// and an object with the shape
// {propName: arrayOfPossiblevalues}
{
disabled: [false, true],
onClick: [action('clicked')],
children: ['hello world', <b>some elements</b>]
}
)
Options
Are provided as 4th argument to addWithPropsCombinations
or set globally using setDefaults
showSource
default: true
Toggles rendering of sample source for each combination.
mustProvideAllProps
default: false
Ensures that possible values are provided for all props listed in propTypes.
CombinationRenderer
A component that renders a single props combination for your component. Receives Component
, props
and options
as props.