Back to Storybook

Storybook for Web components with Vite

docs/get-started/frameworks/web-components-vite.mdx

10.3.61.9 KB
Original Source

Storybook for Web components & Vite is a framework that makes it easy to develop and test UI components in isolation for applications using Web components built with Vite.

Install

To install Storybook in an existing project, run this command in your project's root directory:

<CodeSnippets path="create-command.md" variant="new-users" copyEvent="CreateCommandCopy" />

You can then get started writing stories, running tests and documenting your components. For more control over the installation process, refer to the installation guide.

Requirements

<GetStartedVersions versions={[{ name: 'Vite', range: '≥ 5', icon: '/images/logos/builders/vite.svg' }]} />

Run Storybook

To run Storybook for a particular project, run the following:

<CodeSnippets path="storybook-run-dev.md" />

To build Storybook, run:

<CodeSnippets path="build-storybook-production-mode.md" />

You will find the output in the configured outputDir (default is storybook-static).

FAQ

How do I manually install the Web Components framework?

First, install the framework:

<CodeSnippets path="web-components-vite-install.md" />

Then, update your .storybook/main.js|ts to change the framework property:

<CodeSnippets path="web-components-vite-add-framework.md" />

API

Options

You can pass an options object for additional configuration if needed:

<CodeSnippets path="web-components-vite-framework-options.md" />

The available options are:

builder

Type: Record<string, any>

Configure options for the framework's builder. For this framework, available options can be found in the Vite builder docs.