Socket
Socket
Sign inDemoInstall

@storybook/addon-backgrounds

Package Overview
Dependencies
4
Maintainers
9
Versions
1651
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @storybook/addon-backgrounds

Switch backgrounds to view components in different settings


Version published
Weekly downloads
3.9M
decreased by-17.55%
Maintainers
9
Install size
107 kB
Created
Weekly downloads
 

Package description

What is @storybook/addon-backgrounds?

The @storybook/addon-backgrounds package is a Storybook addon that allows developers to switch between different backgrounds for their components' preview in the Storybook UI. It is useful for visualizing how components look against different backgrounds and can be used to simulate different environments.

What are @storybook/addon-backgrounds's main functionalities?

Setting default backgrounds

This feature allows you to set default backgrounds that will be available for all stories. You can specify a default background that will be pre-selected when a story is loaded.

import { addParameters } from '@storybook/react';
addParameters({
  backgrounds: [
    { name: 'twitter', value: '#00aced', default: true },
    { name: 'facebook', value: '#3b5998' },
  ],
});

Configuring backgrounds for individual stories

This feature allows you to configure backgrounds for individual stories. You can override the default backgrounds for specific stories to tailor the background to the component's needs.

import { storiesOf } from '@storybook/react';
storiesOf('Button', module)
  .addParameters({
    backgrounds: [
      { name: 'dark', value: '#222222' },
      { name: 'light', value: '#eeeeee' },
    ],
  })
  .add('with text', () => <button>Click me</button>);

Other packages similar to @storybook/addon-backgrounds

Changelog

Source

8.0.9

  • Addon-docs: Fix MDX compilation when using @vitejs/plugin-react-swc with plugins - #26837, thanks @JReinhold!
  • CSF: Fix typings for control and other properties of argTypes - #26824, thanks @kasperpeulen!
  • Controls: Fix crashing when docgen extraction partially fails - #26862, thanks @yannbf!
  • Doc Tools: Signature Type Error Handling - #26774, thanks @ethriel3695!
  • Next.js: Move sharp into optional deps - #26787, thanks @shuta13!
  • Nextjs: Support next 14.2 useParams functionality - #26874, thanks @yannbf!
  • Test: Remove chai as dependency of @storybook/test - #26852, thanks @kasperpeulen!
  • UI: Fix sidebar search hanging when selecting a story in touch mode - #26807, thanks @JReinhold!

Readme

Source

Storybook Addon Backgrounds

Storybook Addon Backgrounds can be used to change background colors inside the preview in Storybook.

Framework Support

React Storybook Screenshot

Installation

Backgrounds is part of essentials and so is installed in all new Storybooks by default. If you need to add it to your Storybook, you can run:

npm i -D @storybook/addon-backgrounds

Configuration

Then, add following content to .storybook/main.js:

export default {
  addons: ['@storybook/addon-backgrounds'],
};

Usage

The usage is documented in the documentation.

Keywords

FAQs

Last updated on 22 Apr 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc