New
Storybook’s Visual Tests addon enters betaVisual test with Chromatic
Star82,193
Back to integrations
Add your integration
Categories
  • ⭐️ Popular
  • 🧩 Essentials
  • 🛠 Code
  • ⚡️ Data & state
  • ✅ Test
  • 💅 Style
  • 🎨 Design
  • ⚙️ Appearance
  • 🗄 Organize
How to install addons Create an addon

Integrate Vanilla Extract and Storybook

Get zero-runtime stylesheets in TypeScript. This recipe shows you how to get the most out of Vanilla Extract in Storybook.

Prerequisites

This recipe assumes that you already have an app using Vanilla-extract and have just set up Storybook >= 7.0 using the getting started guide. Don't have this? Follow Vanilla-extract's setup instructions then run:

Terminal
Loading...

Configure your Storybook builder

If you're already using Vanilla Extract in your project, you may already have these dependencies installed.

First of all, install the required dependencies:

Terminal
Loading...

Vite

For Vite users, Storybook uses your project's vite.config.js for its build configuration. This means if your project uses Vanilla Extract, it's also already configured for your Storybook. 🎉

You can view a full example on Stackblitz.

Webpack

For Webpack users, @storybook/addon-styling-webpack can get your Storybook up and running with Vanilla Extract in a few lines of code.

Run the following script to install and register the addon:

Terminal
Loading...

This will run a configuration script that will walk you through setting up the addon. If prompted, select Vanilla Extract as your CSS processor.

Did the configuration script fail?

Under the hood, this command runs npx @storybook/auto-config styling, which is responsible for reading your project and attempting to configure your Storybook Webpack for your desired tools. If running that command directly does not resolve your issue, please consider filing a bug report on the @storybook/auto-config repository so that we can further improve it. For manual configuration instructions for Less, you can refer to the documentation.

Manually configure Webpack

For an example of manual configuration, you can view a full example on Stackblitz.

Get involved

Now you're ready to use Vanilla Extract with Storybook. 🎉 If you use Vanilla Extract at work, we'd love your feedback on the Vanilla Extract + Storybook experience.

Join the maintainers and our thriving community in Discord.

Join the community
6,522 developers and counting
WhyWhy StorybookComponent-driven UI
Open source software
Storybook

Maintained by
Chromatic
Special thanks to Netlify and CircleCI