Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda Storybook Configuration Basics | Storybook Fundamentals and Setup
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Building UI Systems in React with Storybook

bookStorybook Configuration Basics

When you set up Storybook in a React project, you will interact with several key configuration files that control its behavior and appearance. Understanding these files—main.js, preview.js, and manager.js—is essential for tailoring Storybook to your project's needs.

The main.js file is the central configuration point for Storybook. It determines which files Storybook loads as stories, specifies addons, and allows you to customize how Storybook handles different file types. For example, you can point Storybook to look for files with specific extensions or in certain directories. This file is also where you can extend Webpack or Vite configurations if your project requires custom handling for assets, loaders, or plugins.

The preview.js file is responsible for configuring how your stories are rendered in the Storybook preview pane. Here, you can define global decorators, parameters, and any logic that should apply to all stories. This is useful for wrapping all stories with a theme provider, setting up global styles, or defining viewports.

The manager.js file lets you customize the Storybook UI itself. You can change the theme, adjust the layout, or add branding elements to the Storybook interface. This file is particularly useful if you want Storybook to match your product's look and feel or to provide a more branded experience for your team.

Note
Definition

In Storybook, decorators are functions that wrap stories to provide extra context or functionality. They are often used to add providers (such as theme or context providers), apply global styles, or mock data sources. Decorators can be configured globally in preview.js or locally on individual stories, allowing you to control the environment in which each story renders.

question mark

Which of the following configuration files is primarily responsible for specifying which files Storybook loads as stories and which addons are enabled?

Select the correct answer

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 1. Capítulo 4

Pergunte à IA

expand

Pergunte à IA

ChatGPT

Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo

Suggested prompts:

Can you explain more about what goes into each of these configuration files?

How do I customize Storybook's appearance using manager.js?

What are some common use cases for modifying preview.js?

bookStorybook Configuration Basics

Deslize para mostrar o menu

When you set up Storybook in a React project, you will interact with several key configuration files that control its behavior and appearance. Understanding these files—main.js, preview.js, and manager.js—is essential for tailoring Storybook to your project's needs.

The main.js file is the central configuration point for Storybook. It determines which files Storybook loads as stories, specifies addons, and allows you to customize how Storybook handles different file types. For example, you can point Storybook to look for files with specific extensions or in certain directories. This file is also where you can extend Webpack or Vite configurations if your project requires custom handling for assets, loaders, or plugins.

The preview.js file is responsible for configuring how your stories are rendered in the Storybook preview pane. Here, you can define global decorators, parameters, and any logic that should apply to all stories. This is useful for wrapping all stories with a theme provider, setting up global styles, or defining viewports.

The manager.js file lets you customize the Storybook UI itself. You can change the theme, adjust the layout, or add branding elements to the Storybook interface. This file is particularly useful if you want Storybook to match your product's look and feel or to provide a more branded experience for your team.

Note
Definition

In Storybook, decorators are functions that wrap stories to provide extra context or functionality. They are often used to add providers (such as theme or context providers), apply global styles, or mock data sources. Decorators can be configured globally in preview.js or locally on individual stories, allowing you to control the environment in which each story renders.

question mark

Which of the following configuration files is primarily responsible for specifying which files Storybook loads as stories and which addons are enabled?

Select the correct answer

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 1. Capítulo 4
some-alt