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.

Background addon not working

See original GitHub issue

I have applied background addon to my storybook, it is showing those colors as option for selecting as background but on selecting it is not getting applied to my storybook. My config.js looks like this

import { configure, addDecorator, addParameters } from '@storybook/react';
import BItheme from './theme';
import styles from "@sambego/storybook-styles";

addParameters({
  options: {
    theme: BItheme,
  },
  backgrounds: [
    { name: 'twitter', value: '#00aced'},
    { name: 'facebook', value: '#3b5998' },
  ],
});

addDecorator(styles({
  display: 'flex',
  alignItems: 'center',
  justifyContent: 'center',
  height: 500,
}))

// automatically import all files ending in *.stories.js and tsx
configure(
  [
    require.context('../stories', true, /\.stories\.js$/),
    require.context('../src/components', true, /\.stories\.tsx$/)
  ],
  module
);

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:25 (7 by maintainers)

github_iconTop GitHub Comments

40reactions
winterlamoncommented, Dec 2, 2019

I was also having this issue because we import styles (which includes Bootstrap). BS sets background-color on body to white by default. To get around it, I added a stylesheet to Storybook in the .storybook directory (not with our main styles) and imported it into .storybook/config.js.

// .storybook/storybook.scss

.sb-show-main {
  background-color: transparent;
}
// .storybook/config.js

import './storybook.scss'
14reactions
from-niblycommented, Oct 28, 2019

I am also seeing this issue. The problem seems to come from the fact that the body in the iframe has a background-color set to #fff If I remove that css value in developer tools the background addon starts working.

Read more comments on GitHub >

github_iconTop Results From Across the Web

problems with storybook with Background parameters
I'm on a project with a storybook and I want my story to be able to change the background or ...
Read more >
Storybook Addon Background Toggle
Storybook addon to toggle between multiple backgrounds.
Read more >
Custom Background Image and Gear Icon - AnkiWeb
The best solution is to use a smaller file size image for the background so that it loads faster and the flash is...
Read more >
@storybook/addon-backgrounds | Yarn - Package Manager
Storybook Addon Backgrounds can be used to change background colors inside the preview in Storybook. Framework Support. React Storybook Screenshot ...
Read more >
@storybook/addon-backgrounds - npm
Start using @storybook/addon-backgrounds in your project by running `npm i @storybook/addon-backgrounds`. There are 72 other projects in the ...
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