-
-
Notifications
You must be signed in to change notification settings - Fork 9.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to remove preview body padding in SB 6.0? #12109
Comments
try the |
Same issue here, setting isFullscreen: true as per https://storybook.js.org/docs/react/configure/features-and-behavior doesn't fix it. Must admit I haven't dug far but SB is adding style="margin: 0px; padding: 1rem; display: block; justify-content: initial; align-items: initial; min-height: initial;" to body for some reason. |
@coconewty export const parameters = { layout: 'fullscreen' } |
Works great. Thank you. |
Thanks @shilman I missed this. FYI of anyone else hunting for this, it's here... https://storybook.js.org/docs/react/configure/story-layout |
Adding some google search keywords; How to remove default canvas margin in Storybook v6 |
is it possible to disable it for only specific stories? |
Yeah, second that ^^. Our use case is having a few stories which are full app pages (where padding screws up things like screen positioned elements) where we would like to disable padding, but also having component stories (e.g. buttons) where padding makes the viewing of those components nicer |
one solution are decorators but it is annoying set the layout to fullscreen and use decorators on 300 components only for a few pages that needs a fullscreen. |
@mnlfischer you can achieve that by using the
|
misses that in the docs. thanks! |
So to generalise Affects globally import type { Parameters } from '@storybook/react';
export const parameters: Parameters = {
layout: 'fullscreen'
}; Affects all stories in a file import { Meta } from '@storybook/react';
export default {
title: 'Stories Name',
parameters: {
layout: 'fullscreen',
},
} as Meta; Affects single story in a file import { Story } from '@storybook/react';
export const MyStory: Story = () => <div />;
MyStory.parameters = {
layout: 'fullscreen'
} |
Also worth mentioning that you can use the storiesOf('pages/home/story', module)
.add('My story', {}, () => {
return <div>EXAMPLE</div>
})
.addParameters({ layout: 'fullscreen' }); |
@benwinding For what it's worth, we recommend converting your stories from the We've even provided a codemod to help automate this migration: npx sb migrate storiesof-to-csf --glob "src/**/*.stories.js" |
@shilman thanks mate, it will take a while, but could be worth it |
Solution is here: storybookjs/storybook#12109
@iamandrewluca neither one has any effect for me for some reason. Do you need to add some addon for this to have an effect? UPDATE: Never mind. Turns out our Storybook has additional padding on the |
For anyone wondering how to apply this option to individual stories in MDX files: <Story name="Story name" parameters={{layout: 'fullscreen'}}> …or set it for all stories in the document: <Meta
title="Readme title"
component={Component}
parameters={{layout: 'fullscreen'}}
/> |
This does not work (fixed element.style seems to be "padding: 1 rem"):
Any ideas?
The text was updated successfully, but these errors were encountered: