Git Product home page Git Product logo

storybookjs-addon-styling's Introduction

@storybook/addon-styling

Get started in Storybook 7 faster with popular styling tools.

Using Storybook 6? Check out the release-0-3 branch

Toggling between themes

โœจ Features

  • ๐Ÿค– NEW: Zero-config for popular tools through codemods. Read more.
  • ๐Ÿงฉ Configuration templates for popular tools
  • โšก๏ธ Options for css modules, postCss, Sass, and Less
  • ๐ŸŽจ Provide themes
  • ๐Ÿ”„ Toggle between multiple themes when more than one is provided
  • โ—๏ธ Override theme at the component and story level through parameters

๐Ÿ Getting Started

To get started, install the package as a dev dependency

yarn:

yarn add -D @storybook/addon-styling

npm:

npm install -D @storybook/addon-styling

pnpm:

pnpm add -D @storybook/addon-styling

Then, include the addon in your .storybook/main.js file

module.exports = {
  stories: [
    "../stories/**/*.stories.mdx",
    "../stories/**/*.stories.@(js|jsx|ts|tsx)",
  ],
  addons: [
    "@storybook/addon-essentials",
+   "@storybook/addon-styling"
  ],
};

๐Ÿ‘‡ Tool specific configuration

For tool-specific setup, check out the recipes below

Don't see your favorite tool listed? Don't worry! That doesn't mean this addon isn't for you. Check out the "Writing a custom decorator" section of the api reference.

โ—๏ธ Overriding theme

If you want to override your theme for a particular component or story, you can use the theming.themeOverride parameter.

import React from "react";
import { Button } from "./Button";

export default {
  title: "Example/Button",
  component: Button,
  parameters: {
    theming: {
      themeOverride: "light", // component level override
    },
  },
};

const Template = (args) => <Button {...args} />;

export const Primary = Template.bind({});
Primary.args = {
  primary: true,
  label: "Button",
};

export const PrimaryDark = Template.bind({});
PrimaryDark.args = {
  primary: true,
  label: "Button",
};
PrimaryDark.parameters = {
  theming: {
    themeOverride: "dark", // Story level override
  },
};

๐Ÿค Contributing

If you'd like to contribute to this addon, THANK YOU, I'd love your help ๐Ÿ™

๐Ÿ“ Development scripts

  • yarn start runs babel in watch mode and starts Storybook
  • yarn build build and package your addon code

๐ŸŒฒ Branch structure

  • next - the next version on npm, and the development branch where most work occurs
  • main - the latest version on npm and the stable version that most users use

๐Ÿš€ Release process

  1. All PRs should target the next branch, which depends on the next version of Storybook.
  2. When merged, a new version of this package will be released on the next NPM tag.
  3. If the change contains a bugfix that needs to be patched back to the stable version, please note that in PR description.
  4. PRs labeled pick will get cherry-picked back to the main branch and will generate a release on the latest npm tag.

storybookjs-addon-styling's People

Contributors

shaunevening avatar damianstasik avatar karibash avatar pahan35 avatar regisfrey avatar valentinpalkovic avatar munawiki avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.