Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
@storybook/addon-backgrounds
Advanced tools
Switch backgrounds to view components in different settings
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.
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>);
The @storybook/addon-knobs package allows you to edit React props dynamically using the Storybook UI. It is similar to @storybook/addon-backgrounds in that it enhances the Storybook experience by allowing for real-time changes to the component's environment, but it focuses on props rather than backgrounds.
The @storybook/addon-actions package can be used to display data received by event handlers in Storybook. It is similar to @storybook/addon-backgrounds in that it helps in visualizing and debugging components, but it focuses on capturing and displaying actions rather than changing backgrounds.
The @storybook/addon-viewport package allows you to adjust the viewport size and layout for responsive design testing within Storybook. While @storybook/addon-backgrounds changes the background behind components, @storybook/addon-viewport changes the size of the frame that the component is rendered within.
Storybook Addon Backgrounds can be used to change background colors inside the preview in Storybook.
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
Then, add following content to .storybook/main.js
:
export default {
addons: ['@storybook/addon-backgrounds'],
};
The usage is documented in the documentation.
8.4.0
Storybook 8.4 comes with a ton of exciting new features designed to give you the best experience developing, testing, and debugging tests in the browser!
@vitest/browser
v2.1.2 - #29407, thanks @strozw!es-toolkit
- #29259, thanks @JReinhold!@storybook/addon-links
by default - #29177, thanks @tobiasdiez!.gitignore
updated via CLI ends with a newline - #29124, thanks @3w36zj6!yarn
detection - #29448, thanks @ndelangen!chalk
to picocolors
- #28262, thanks @43081j!export { X }
parsing - #29344, thanks @vctqs1!prettier
an optional peer dependency - #29223, thanks @JReinhold!express
to polka
- #29230, thanks @43081j!qs
to picoquery
- #28315, thanks @43081j!handlebars
usage - #29208, thanks @ndelangen!file-system-cache
- #29256, thanks @ndelangen!fs-extra
with the native APIs - #29126, thanks @ziebam!lodash
with es-toolkit
- #28981, thanks @ndelangen!esbuild
, broadening version range - #29254, thanks @ndelangen!renderers/react
's dependencies - #29298, thanks @ndelangen!svelte2tsx
- support runes - #29423, thanks @JReinhold!util
dependency - #29310, thanks @JReinhold!react
in manager - #29197, thanks @ndelangen!optimizeDeps
- #29179, thanks @tobiasdiez!FAQs
Switch backgrounds to view components in different settings
The npm package @storybook/addon-backgrounds receives a total of 4,043,778 weekly downloads. As such, @storybook/addon-backgrounds popularity was classified as popular.
We found that @storybook/addon-backgrounds demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
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.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.