Socket
Socket
Sign inDemoInstall

@storybook/react

Package Overview
Dependencies
884
Maintainers
5
Versions
1697
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @storybook/react

Storybook for React: Develop React Component in isolation with Hot Reloading.


Version published
Weekly downloads
4M
decreased by-9.6%
Maintainers
5
Install size
143 MB
Created
Weekly downloads
 

Package description

What is @storybook/react?

@storybook/react is a development environment for UI components. It allows developers to create components independently and showcase components interactively in an isolated development environment. Storybook helps in building UI components in isolation from the business logic and context of the app, which makes it easier to develop hard-to-reach states and edge cases.

What are @storybook/react's main functionalities?

Component Story Format (CSF)

CSF is an ES Module-based standard for defining component examples. This format is simple and portable. Developers can write their component stories in plain JavaScript objects.

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

export default {
  title: 'Example/Button',
  component: Button,
};

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

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

Addons

Addons are essentially plugins that extend Storybook's core functionalities. With addons, developers can add features like knobs to dynamically change props, accessibility checks, and story source code display.

import { withKnobs, text, boolean, number } from '@storybook/addon-knobs';

export default {
  title: 'Example/Button',
  decorators: [withKnobs],
};

export const DynamicVariables = () => {
  const name = text('Name', 'Aragon');
  const age = number('Age', 30);
  const content = `I am ${name} and I'm ${age} years old.`;
  return <div>{content}</div>;
};

Controls

Controls give the ability to interact with a component's arguments dynamically without needing to code. It's a more robust version of the addon-knobs but built into Storybook by default.

export default {
  title: 'Example/Button',
  component: Button,
  argTypes: {
    backgroundColor: { control: 'color' },
    size: {
      control: { type: 'select', options: ['small', 'medium', 'large'] },
    },
  },
};

export const Primary = (args) => <Button {...args} />;
Primary.args = {
  primary: true,
  label: 'Button',
};

Other packages similar to @storybook/react

Readme

Source

Storybook for React

Storybook for React is a UI development environment for your React components. With it, you can visualize different states of your UI components and develop them interactively.

Storybook Screenshot

Storybook runs outside of your app. So you can develop UI components in isolation without worrying about app specific dependencies and requirements.

Getting Started

cd my-react-app
npx sb init

For more information visit: storybook.js.org


Storybook also comes with a lot of addons and a great API to customize as you wish. You can also build a static version of your Storybook and deploy it anywhere you want.

Here are some featured storybooks that you can reference to see how Storybook works:

Create React App

Support for Create React App is handled by @storybook/preset-create-react-app.

This preset enables support for all Create React App features, including Sass/SCSS and TypeScript.

If you're working on an app that was initialized manually (i.e., without the use of Create React App), ensure that your app has react-dom included as a dependency. Failing to do so can lead to unforeseen issues with Storybook and your project.

Typescript

@storybook/react is now exporting its own types to use with Typescript. You don't need to have @types/storybook__react installed anymore if it was your case. But you probably also need to use types from @types/node @types/react.

Docs

Keywords

FAQs

Last updated on 26 Jan 2023

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