question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Global preview-head.html for Storybook

See original GitHub issue

Expected Behavior

If I add a preview-head.html in the root .storybook directory, to add custom styles (like Angular Material Icons) to Storybook, I would expect them to be applied to all storybook instances in the workspace.

Current Behavior

I have to add the same preview-head.html in the .storybook directory of all libs.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:12
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

6reactions
mandarinicommented, Sep 25, 2020

Hi @twittwer . It’s in our plans to address this issue with a schematic, possibly, along with other extra config files for Storybook. I’ll keep this issue updated.

5reactions
wizardnet972commented, Aug 13, 2021

@twittwer for now, you can use this solution: (for global use. at .storybook folder in the root)

module.exports = {
  stories: ...,
  addons: ...,
  previewHead: (head) => `
    ${head}
    <style>
       * {border: 1px solid red;}
    </style>
  ` 
  ....
Read more comments on GitHub >

github_iconTop Results From Across the Web

Story rendering - Storybook
Similarly to the preview head HTML, preview body HTML can also be updated programmatically using a preset. See Preview/Manager templates for more information....
Read more >
6 Ways To Configure Global Styles for Storybook | by Jennifer Fu
In Storybook, stories are rendered in a particular “preview” iframe (the Canvas tab). The Storybook web application reads .storybook/preview-head.html if it ...
Read more >
Configuring Storybook: 6 Tips You Can't Miss | by Zheng Li
Use preview.js for global code (such as CSS imports or JavaScript mocks) that applies to all stories. The preview.js file can be ...
Read more >
Getting Started - Page ⋅ Storybook - Primer Design System
preview.js: customizations, decorators, global CSS imports. preview-head.html: story-level "global" styles (within the story iframe). Accessibility Controls
Read more >
Add Custom Head Tags - Storybook
This is useful for adding web fonts or some external scripts. You can do this very easily. Simply create a file called preview-head.html...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found