Skip to main content

Addon

While storybook-addon-badges can be used out of the box, some of the most powerful features are opt-in, to ensure that they don't conflict with how you use Storybook.

You can configure using the manager file (recommended), or the preview file in your .storybook/ configuration folder.

Configuring via the manager configuration file is the recommended method as it ensures that all options are available, and allows you to pass functions to certain configuration items.

To set the addon configuration, pass in your config options under the badgeConfig key of the object passed to addons.setConfig:

.storybook/manager.ts
import { addons } from '@storybook/addons';

addons.setConfig({
// ...rest of config
badges: ['version:1.0.0'], // 👈 You can also pass in global badges here if not using tags.
badgesConfig: {
// ...addon config here
};
})

Options​

Below are the various configuration options available and what they do. For more information on a particular option, click the option's name in the table below.

OptionDescriptionDefault
autobadgesAllows you to automatically add badges to a story based on triggers.['new', 'updated']
badgeMapDefine the badges available to display.See pre-defined badges
baseStyleThe style that badges use by default. Any values not defined will fall back to this.See base style
delimiterThe string used to separate a badge's ID from its content.':'
displayContentOnlyWhether to display just the content part of a badge. Can be overridden for each badge.false
excludeTagsList of tags to prevent from generating badges.['autodocs', 'dev', 'test', 'attached-mdx', 'unattached-mdx']
locationsDefault locations for badges to display.['toolbar']
matchersAllows for complex logic and badge mapping.[]
markAllAsReadOnDocsViewWhen using autobadges for new and updated, whether to remove the badge from all stories for a component when its docs page is viewed.true
replaceDefaultBadgeMapAllows a custom badge map to completely override the built-in badges, rather than extend.false
separatorsHow to display separators in the different locations.
sidebarDisplayBadgesThe number of badges to display on the sidebar to prevent it getting cluttered.all
useMatcherBadgeFallbackWhen using matchers, whether to fallback to default badge mapping if no matchers match.false
useTagsWhether to generate badges from tags.false
warnOnLegacyConfigWhether to display the warning when using 'legacy' configuration.true

Warn On Legacy Config​

info

As using parameters to configure storybook-addon-badges is considered legacy, you may see a warning pop up the first time you load a Storybook. This will only be shown once (per user, as it uses localStorage), and serves a reminder to migrate to the more powerful manager-based configuration if you've just upgraded.

If, however, you have a reason to keep using parameters, and want to remove this warning from ever showing on published Storybooks, you can pass in warnOnLegacyConfig: false to the badgesConfig and this will prevent the warning from showing.