Can't change background of canvas
See original GitHub issueDescribe the bug I can’t change the background of the canvas. Also looking at the tutorials the canvas should have white background but for some reason mine is grey.
To Reproduce Clone repo at: https://github.com/jauggy/storybook-background-issues
npm i
npm run storybook
Notice the Canvas background is gray. Also when clicking the background addons you can’t change it.
Expected behavior White background on canvas and ability to change the canvas background via the background addon.
Screenshots
If applicable, add screenshots to help explain your problem.
Code snippets If applicable, add code samples to help explain your problem.
System:
Environment Info:
System:
OS: Windows 10 10.0.19041
CPU: (4) x64 Intel(R) Core(TM) i5-2500 CPU @ 3.30GHz
Binaries:
Node: 12.18.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.4 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 6.14.5 - C:\Program Files\nodejs\npm.CMD
Browsers:
Chrome: 84.0.4147.135
Edge: Spartan (44.19041.423.0), Chromium (85.0.564.41)
npmPackages:
@storybook/addon-essentials: ^6.0.20 => 6.0.20
@storybook/react: ^6.0.20 => 6.0.20
Additional context Add any other context about the problem here.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:13 (6 by maintainers)
Top Results From Across the Web
Why can't I change the background of my canvas?
You need to specify the background colour in the style attribute, like this: style="border:4px solid black; background-color: yellow".
Read more >Why Power BI Canvas Background Color is not Changing
Power BI tutorial for beginners to understand why the canvas background color doesn't change even after changing the color and what setting ...
Read more >Why Power BI Canvas Background Color is not Changing
Power BI tutorial for beginners to understand how to make settings in power bi canvas to make sure background color changes.
Read more >Solved: Canvas extension color for the background cannot c...
Press X to switch foreground/background. The standard way to set a background color is to click the background swatch in the toolbar.
Read more >Solved: Background Color - Instructure Community
Is there a way to change the background color on a page? I have tried HTML code & it doesn't work. Solved! Go...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hey @jauggy thanks a lot for putting up a reproduction! It helps a lot. The reason the addon does not work is that the lib you’re using, CoreUI, sets a default background color at the body level. This is the line of code that gives the side effect:
In storybook 6.0, the background is set at the iframe level, which is less specific than the body. In Storybook 6.1 this problem is fixed. This is your storybook running with
^6.1.0-alpha.23
:Also, Storybook 6 supports typescript out of the box! So you can remove these lines from your main.js:
You can also use main.ts and preview.(ts|tsx)!
I had the same issue in 6.0.5 (docs Canvas elements not using the same background-color that they do in the sandbox mode) but this issue appears to be solved by updating to Storybook 6.1.1.