Styling Addon: configure styles and themes in StorybookAutomate with Chromatic
Storybook Day 2023
Back to integrations
Add your integration
  • ⭐️ Popular
  • 🧩 Essentials
  • 🛠 Code
  • ⚡️ Data & state
  • ✅ Test
  • 💅 Style
  • 🎨 Design
  • ⚙️ Appearance
  • 🗄 Organize
How to install addons Create an addon
HTML preview
A Storybook addon that extracts and displays compiled syntax-highlighted HTML
npm install @elliason/storybook-addon-html
Last updated 12 months ago
Downloads per week
Readme View on GitHub

Storybook Addon HTML Adjustments

This fork is adjusted version of

If you are not sure which version you should use, always use the original one.

The reason for this fork was ability to dispatch message html-plugin-code-received to story's iframe, after rendered HTML code is updated.

    useEffect(() => {
        setCode(prettierFormat(html, prettierConfig));
        const event = new Event('html-plugin-code-received');
    }, [html]);

Storybook Addon HTML

This addon for Storybook adds a tab that displays the compiled HTML for each story. It uses highlight.js for syntax highlighting.

Animated preview

Getting Started

With NPM:

npm i --save-dev @whitespace/storybook-addon-html

With Yarn:

yarn add -D @whitespace/storybook-addon-html

Register addon

// .storybook/main.js

module.exports = {
  // ...
  addons: [
    // ...


The HTML is formatted with Prettier. You can override the Prettier config (except parser and plugins) by providing an object following the Prettier API override format in the html parameter:

// .storybook/preview.js

export const parameters = {
  // ...
  html: {
    prettier: {
      tabWidth: 4,
      useTabs: false,
      htmlWhitespaceSensitivity: 'strict',

You can override the wrapper element selector used to grab the component HTML.

export const parameters = {
  html: {
    root: '#my-custom-wrapper', // default: #root

When using Web Components, the HTML will contain empty comments, i.e. <!---->. If you want to remove these, use the removeEmptyComments parameter:

export const parameters = {
  html: {
    removeEmptyComments: true, // default: false

You can override the showLineNumbers and wrapLines settings for the syntax highlighter by using the highlighter parameter:

export const parameters = {
  html: {
    highlighter: {
      showLineNumbers: true, // default: false
      wrapLines: false, // default: true

Supported frameworks

As of version 4.0.0 all frameworks are supported per default 🎉

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

Maintained by
Special thanks to Netlify and CircleCI