Tag Editor
Edit story and component tags from the Storybook sidebar
๐ Table of Contents
- ๐ Table of Contents
- ๐ฆ Installation
- ๐ Usage
- ๐ Limitations
- ๐ฉ๐ฝโ๐ป Contributing
- ๐ Support
- โ๏ธ Contact
- ๐ Acknowledgments
๐ฆ Installation
[!IMPORTANT] It also uses the sidebar context menu API from storybook#36316, which is not released yet. Until it ships, you need a canary build of Storybook.
// package.json
{
"devDependencies": {
"storybook": "https://pkg.pr.new/storybook@aa7e796",
"@storybook/react-vite": "https://pkg.pr.new/@storybook/react-vite@aa7e796"
}
}
This addon needs Storybook 11 and Node 22.12 or later. Install it in one step with the Storybook CLI:
pnpx storybook add storybook-addon-tag-editor
Or install it manually, by adding the development dependency and editing main.ts and preview.ts:
pnpm add -D storybook-addon-tag-editor
Register the addon in .storybook/main.ts:
// .storybook/main.ts
import { defineMain } from '@storybook/react-vite/node';
export default defineMain({
addons: ['storybook-addon-tag-editor'],
});
And in .storybook/preview.ts, alongside your other addons:
// .storybook/preview.ts
import { definePreview } from '@storybook/react-vite';
import tagEditor from 'storybook-addon-tag-editor';
export default definePreview({
addons: [tagEditor()],
});
๐ Usage
Hover or focus a docs page, component or story in the sidebar, open its context menu, and pick Edit tags. Note that component autodocs do not have tags, so the menu option is missing for those entries.
The editor UI lets you add, remove and invert tags, and create new tags. It shows tags inherited from a parent component or the global preview configuration.
Please provide feedback if you or your users find it difficult to understand and use the editor UI.
๐ Limitations
Dev Mode Only
Storybook renders the sidebar context menu in development only, so the addon does nothing in a built Storybook.
Static Tags and Default CSF Only
The addon reads and writes tags with csf-tools for CSF files and remark for MDX. Both need a literal array of strings.
Tags injected into stories via the Indexer API can be edited, but edits will not persist as they are not actually derived from CSF files. Custom CSF formats like Svelte CSF are not supported.
Formatting
csf-tools is unaware of your formatting and linting preferences. Run your formatter after editing tags in the UI and prior to committing your changes.
๐ฉ๐ฝโ๐ป Contributing
Code of Conduct
Please read the Code of Conduct first.
Developer Certificate of Origin
To ensure that contributors are legally allowed to share the content they contribute under the license terms of this project, contributors must adhere to the Developer Certificate of Origin (DCO). All contributions made must be signed to satisfy the DCO. This is handled by a Pull Request check.
By signing your commits, you attest to the following:
- The contribution was created in whole or in part by you and you have the right to submit it under the open source license indicated in the file; or
- The contribution is based upon previous work that, to the best of your knowledge, is covered under an appropriate open source license and you have the right under that license to submit that work with modifications, whether created in whole or in part by you, under the same open source license (unless you are permitted to submit under a different license), as indicated in the file; or
- The contribution was provided directly to you by some other person who certified 1., 2. or 3. and you have not modified it.
- You understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information you submit with it, including your sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved.
Getting Started
This project uses PNPM as a package manager, and needs Node 22.12 or later.
- See the installation instructions for PNPM
- Run
pnpm i
Useful commands
pnpm startbuilds the addon in watch mode and starts the local Storybookpnpm buildbuilds and packages the addon codepnpm testruns the test suite,pnpm test:coverageadds a coverage reportpnpm checktype-checks the sourcepnpm lintruns ESLint and Prettier
Release System
This package auto-releases on pushes to main with semantic-release. No changelog is maintained and the version number in package.json is not synchronised.
๐ Support
Please open an issue for bug reports or code suggestions. Make sure to include a working Minimal Working Example for bug reports.
โ๏ธ Contact
Steve Dodier-Lazaro ยท @Frog on the Storybook Discord - LinkedIn
Project Link: https://github.com/Sidnioulz/storybook-addon-tag-editor
๐ Acknowledgments
Thanks
- Stefan Ganswint for creating the first prototype of a tag editor
- All the contributors to the Storybook addon kit