Back to integrations
Add your integration
Categories
  • ⭐️ Popular
  • 🧩 Essentials
  • 🛠 Code
  • ⚡️ Data & state
  • ✅ Test
  • 💅 Style
  • 🎨 Design
  • ⚙️ Appearance
  • 🗄 Organize
How to install addons Create an addon
Paddings
Add paddings to view components under different white space settings
npm install storybook-addon-paddings
Last updated 4 months ago
19.2k
Downloads per week
Readme View on GitHub

Storybook Paddings Addon

npm package version Build status Dependencies status

🔲 A Storybook addon to add different paddings to your preview. Useful for checking how components behave when surrounded with white space.

Demo

View demo →

Installation

npm install --save-dev storybook-addon-paddings
// .storybook/main.js
export default {
  addons: ['storybook-addon-paddings'],
}

// .storybook/preview.js
export default {
  parameters: {
    layout: 'fullscreen', // remove default Storybook padding
  },
}

Configuration

The paddings toolbar comes with small, medium and large options by default, but you can configure your own set of paddings via the paddings parameter.

To configure for all stories, set the paddings parameter in .storybook/preview.js:

export const parameters = {
  paddings: {
    values: [
      { name: 'Small', value: '16px' },
      { name: 'Medium', value: '32px' },
      { name: 'Large', value: '64px' },
    ],
    default: 'Medium',
  },
}

You can also configure on per-story or per-component basis using parameter inheritance:

// Button.stories.js

// Set padding options for all Button stories
export default {
  title: 'Button',
  component: Button,
  parameters: {
    paddings: {
      values: [
        { name: 'Small', value: '16px' },
        { name: 'Medium', value: '32px' },
        { name: 'Large', value: '64px' },
      ],
      default: 'Large',
    },
  },
}

// Disable addon in Button/Large story only
export const Large {
  parameters: {
    paddings: { disable: true },
  },
}

See other story examples.

Join the community
6,615 developers and counting
WhyWhy StorybookComponent-driven UI
DocsGuidesTutorialsChangelogTelemetryStatus
CommunityAddonsGet involvedBlog
ShowcaseExploreProjectsComponent glossary
Open source software
Storybook

Maintained by
Chromatic
Special thanks to Netlify and CircleCI