> For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.

# Web Components

Storybook for Web Components & Rsbuild is tailored for Lit and custom-element projects, giving you fast component previews without leaving your Rsbuild workflow.

## Requirements


| Package | Version |
| --- | --- |
| `lit` | ≥ 2 (or ≥ 3) |
| `@rsbuild/core` | `^1.5.0 \|\| ^2.0.0-0` |
| `storybook` | `^10.6.0` |


## Getting started

Run through these steps inside an Rsbuild project that renders Web Components.

### Installation

Install the Web Components framework package and `@rsbuild/core`. Even though `storybook-web-components-rsbuild` declares `@rsbuild/core` as a peer, list it as a direct dev dependency so version pins and lockfile audits remain unambiguous.


```sh [npm]
npm install @rsbuild/core storybook-web-components-rsbuild -D
```

```sh [yarn]
yarn add @rsbuild/core storybook-web-components-rsbuild -D
```

```sh [pnpm]
pnpm add @rsbuild/core storybook-web-components-rsbuild -D
```

```sh [bun]
bun add @rsbuild/core storybook-web-components-rsbuild -D
```

```sh [deno]
deno add npm:@rsbuild/core npm:storybook-web-components-rsbuild -D
```

### Configure `.storybook/main.ts`

```js
import { StorybookConfig } from 'storybook-web-components-rsbuild'
import { mergeRsbuildConfig } from '@rsbuild/core'

const config: StorybookConfig = {
  framework: 'storybook-web-components-rsbuild',
  stories: ['../src/**/*.stories.@(js|mjs|ts)'],
  rsbuildFinal: (config) => {
    // Customize the final Rsbuild config here
    return mergeRsbuildConfig(config, {
      // your custom config
    })
  },
}

export default config
```

You're good to go! See the [web components sandbox](https://github.com/rstackjs/storybook-rsbuild/tree/main/sandboxes/lit) for a complete reference and browse the [Storybook docs](https://storybook.js.org/docs) for deeper guidance.

## Next Steps

- **[Writing Stories](https://storybook.js.org/docs/writing-stories)**: Learn the basics of CSF for Web Components.
- **[Lit Snippets](https://storybook.js.org/docs/get-started/frameworks/web-components-vite)**: Examples using Lit and generic Web Components.

## Options

Please refer to the [Configuration Guide](/guide/configuration.md#framework-options) for framework-specific options and defaults.
