Hello,
Do you think margin around a component can be removed in full screen mode?
Use case: testing {height: 100vh} components.
If this idea sounds good, I will try to look into it.
@MykolaGolubyev In my own project, I've added some basic body
styles to preview-head.html
to work around this:
<style type="text/css">
body {
margin: 0;
padding: 0;
}
</style>
The bigger question, of course, is if something like this should be the default for the preview iframe.
We have any reset.css
sort of thing implemented for the Storybook iframe so the margin is probably your browser's default style getting rendered.
I don't think we should be overriding default browser behavior because that's helpful for catching browser specific bugs/behaviors. If you'd like to change your specific usage, @kohlmannj's solution is the best way to go.
I agree with @danielduan, this is exactly why the preview-head.html
option is there.
Another option would be to expand the addon-viewport
with some additional functionality:
setting padding/margin and possible also centering...
The storybook iframe (#storybook-preview-iframe) has a default margin (the chrome puts 8px margin on iframe). Components with 100vh broken, with a scrollbar :(
@joseneto-fixeads did you try to add preview-head.html
file? https://storybook.js.org/configurations/add-custom-head-tags/
@Hypnosphi , Thanks! this solved the problem. I read already about this file, but I don't find him. I don't know the file must be created. Thanks!!!!
How about a decorator for stories? myStory.addDecorator(withBorderless);
A simple and still customizable plugin like solution via a decorator. We inject a style tag that overrides the body class in the iframe.
Add file to .storybook/addons/no-border.js
-> export default story => <style>.sb-show-main{margin: 0}</style>${story()}
In the story
import { storiesOf } from '@storybook/html'; // or react
import noBorder from '<path_back_to_root>.storybook/addons/no-border';
storiesOf('MyStory', module)
.addDecorator(noBorder)
...
Does not seem to work in SB 6 anymore?
try layout: 'fullscreen'
story parameter
@Obiwarn Doesn't work for me either with SB 6..
The issue is that there seem to be inline styles in the storybook by default. Not sure how to remove these
find the solution here:
Thanks a lot, @Obiwarn . Solves the problem well.
try
layout: 'fullscreen'
story parameter
work like a charm
Most helpful comment
@MykolaGolubyev In my own project, I've added some basic
body
styles topreview-head.html
to work around this:The bigger question, of course, is if something like this should be the default for the preview iframe.