'
+ );
+ });
});
diff --git a/app/react/src/client/docs/jsxDecorator.tsx b/app/react/src/client/docs/jsxDecorator.tsx
index 727ee31e5f98..20a294ea35f8 100644
--- a/app/react/src/client/docs/jsxDecorator.tsx
+++ b/app/react/src/client/docs/jsxDecorator.tsx
@@ -177,7 +177,6 @@ export const jsxDecorator = (
) => {
const channel = addons.getChannel();
const skip = skipJsxRender(context);
- const story = storyFn();
let jsx = '';
@@ -185,6 +184,7 @@ export const jsxDecorator = (
if (!skip) channel.emit(SNIPPET_RENDERED, (context || {}).id, jsx);
});
+ const story = storyFn();
// We only need to render JSX if the source block is actually going to
// consume it. Otherwise it's just slowing us down.
if (skip) {
diff --git a/app/react/src/server/framework-preset-react-docs.test.ts b/app/react/src/server/framework-preset-react-docs.test.ts
index bd86e13da568..7ed80a8cf5f0 100644
--- a/app/react/src/server/framework-preset-react-docs.test.ts
+++ b/app/react/src/server/framework-preset-react-docs.test.ts
@@ -32,7 +32,7 @@ describe('framework-preset-react-docgen', () => {
presets: ['env', 'foo-preset'],
overrides: [
{
- test: /\.(mjs|tsx?|jsx?)$/,
+ test: /\.(cjs|mjs|tsx?|jsx?)$/,
plugins: [
[
babelPluginReactDocgenPath,
diff --git a/app/react/src/server/framework-preset-react-docs.ts b/app/react/src/server/framework-preset-react-docs.ts
index 1e9a1e74cfb1..675d31487c75 100644
--- a/app/react/src/server/framework-preset-react-docs.ts
+++ b/app/react/src/server/framework-preset-react-docs.ts
@@ -21,7 +21,7 @@ export async function babel(config: TransformOptions, options: Options) {
overrides: [
...(config?.overrides || []),
{
- test: reactDocgen === 'react-docgen' ? /\.(mjs|tsx?|jsx?)$/ : /\.(mjs|jsx?)$/,
+ test: reactDocgen === 'react-docgen' ? /\.(cjs|mjs|tsx?|jsx?)$/ : /\.(cjs|mjs|jsx?)$/,
plugins: [
[
require.resolve('babel-plugin-react-docgen'),
diff --git a/docs/addons/writing-addons.md b/docs/addons/writing-addons.md
index 071ac289e240..6245585bda3d 100644
--- a/docs/addons/writing-addons.md
+++ b/docs/addons/writing-addons.md
@@ -66,7 +66,7 @@ We'll need to add the necessary dependencies and make some adjustments. Run the
Initialize a local Storybook instance to allow you to test your addon.
```shell
-npx sb init
+npx storybook init
```
diff --git a/docs/builders/overview.md b/docs/builders/overview.md
index f7395953f7e4..45869adcb7e3 100644
--- a/docs/builders/overview.md
+++ b/docs/builders/overview.md
@@ -8,12 +8,12 @@ Storybook, at its core, is powered by builders such as Webpack and Vite. These b
## CLI basics
-Before diving into setting up Storybook's builders, let's look at how the CLI configures them. When you initialize Storybook (via `npx sb init`), the CLI automatically detects which builder to use based on your application. For example, if you're working with Vite, it will install the Vite builder. If you're working with Webpack, it installs the Webpack builder based on your current version.
+Before diving into setting up Storybook's builders, let's look at how the CLI configures them. When you initialize Storybook (via `npx storybook init`), the CLI automatically detects which builder to use based on your application. For example, if you're working with Vite, it will install the Vite builder. If you're working with Webpack, it installs the Webpack builder based on your current version.
Additionally, you can also provide a flag to Storybook's CLI and specify the builder you want to use:
```shell
-npx sb init --builder
+npx storybook init --builder
```
## Manual setup
diff --git a/docs/builders/vite.md b/docs/builders/vite.md
index bd43e267830d..7bd7eadfcbd6 100644
--- a/docs/builders/vite.md
+++ b/docs/builders/vite.md
@@ -9,7 +9,7 @@ Storybook Vite builder bundles your components and stories with [Vite](https://v
## Setup
-If you ran `npx sb init` to include Storybook in your Vite application, the builder is already installed and configured for you. If you want, you can also opt into it manually.
+If you ran `npx storybook init` to include Storybook in your Vite application, the builder is already installed and configured for you. If you want, you can also opt into it manually.
Run the following command to install the builder.
diff --git a/docs/configure/babel.md b/docs/configure/babel.md
index a1af175354ef..827fc2621a81 100644
--- a/docs/configure/babel.md
+++ b/docs/configure/babel.md
@@ -81,7 +81,7 @@ For detailed instructions on migrating from `V6` mode, please see [MIGRATION.md]
If your app does not include a babelrc file, and you need one, you can create it by running the following command in your project directory:
```sh
-npx sb@next babelrc
+npx storybook@next babelrc
```
Once the command completes, you should have a `.babelrc.json` file created in the root directory of your project, similar to the following example:
diff --git a/docs/configure/upgrading.md b/docs/configure/upgrading.md
index d4f93edb3312..08ac9d49be0a 100644
--- a/docs/configure/upgrading.md
+++ b/docs/configure/upgrading.md
@@ -11,7 +11,7 @@ The most common upgrade is Storybook itself. [Storybook releases](https://storyb
To help ease the pain of keeping Storybook up-to-date, we provide a command-line script:
```sh
-npx sb upgrade
+npx storybook upgrade
```
This upgrades all of the Storybook packages in your project to the latest stable version, perform confidence checks of your package versions, and checks for opportunities to run [automigrations](#automigrate) to update your configuration automatically.
@@ -27,10 +27,10 @@ In addition to running the command, we also recommend checking the [MIGRATION.md
Storybook upgrades are not the only thing to consider: changes in the ecosystem also present challenges. For example, lots of frameworks ([Angular 12](https://angular.io/guide/updating-to-version-12#breaking-changes-in-angular-version-12), [Create React App v5](https://github.com/facebook/create-react-app/pull/11201), [NextJS](https://nextjs.org/docs/upgrading#webpack-5)) have recently migrated from [Webpack 4 to Webpack 5](https://webpack.js.org/migrate/5/), so even if you don't upgrade your Storybook version, you might need to update your configuration accordingly. That's what Automigrate is for:
```
-npx sb@next automigrate
+npx storybook@next automigrate
```
-It runs a set of standard configuration checks, explains what is potentially out-of-date, and offers to fix it for you automatically. It also points to the relevant documentation so you can learn more. It runs automatically as part of [`sb upgrade`](#upgrade-script) command, but it's also available on its own if you don't want to upgrade Storybook.
+It runs a set of standard configuration checks, explains what is potentially out-of-date, and offers to fix it for you automatically. It also points to the relevant documentation so you can learn more. It runs automatically as part of [`storybook upgrade`](#upgrade-script) command, but it's also available on its own if you don't want to upgrade Storybook.
## Prereleases
@@ -39,11 +39,13 @@ In addition to the above, Storybook is under constant development, and we publis
To upgrade to the latest pre-release:
```sh
-npx sb@next upgrade --prerelease
+npx storybook@next upgrade --prerelease
```
If you'd like to downgrade to a stable version, manually edit the package version numbers in your `package.json` and re-install.
+
Storybook collects completely anonymous data to help us improve user experience. Participation is optional, and you may [opt-out](../configure/telemetry.md#how-to-opt-out) if you'd not like to share any information.
+
diff --git a/docs/contribute/code.md b/docs/contribute/code.md
index 8b55caa63fe4..d59237c6fe1d 100644
--- a/docs/contribute/code.md
+++ b/docs/contribute/code.md
@@ -136,7 +136,7 @@ We encourage bug reports to include reproductions. In the same way that it's pos
To do so, run the following command in the root of the monorepo:
```shell
-npx sb@next link https://github.com/your-username/your-project.git
+npx storybook@next link https://github.com/your-username/your-project.git
```
This command creates a project `../storybook-repros/your-project`, and automatically links it to your local Storybook code. After connecting it, you should be able to run Storybook and develop as mentioned [above](#start-developing).
@@ -144,11 +144,11 @@ This command creates a project `../storybook-repros/your-project`, and automatic
If you already have a reproduction on your local machine, you can similarly link it to your monorepo dev setup with the `--local` flag:
```shell
-npx sb@next link --local /path/to/local-repro-directory
+npx storybook@next link --local /path/to/local-repro-directory
```
-π‘ The sb link command relies on yarn 2 linking under the hood. It requires that the local repro is using yarn 2, which will be the case if you're using the [sb repro command](./how-to-reproduce) per our contributing guidelines. If you are trying to link to a non-yarn 2 project, linking will fail.
+π‘ The storybook link command relies on yarn 2 linking under the hood. It requires that the local repro is using yarn 2, which will be the case if you're using the [storybook repro command](./how-to-reproduce) per our contributing guidelines. If you are trying to link to a non-yarn 2 project, linking will fail.
## Troubleshooting
diff --git a/docs/contribute/how-to-reproduce.md b/docs/contribute/how-to-reproduce.md
index ebc2ae7f39f3..2936c2be92a7 100644
--- a/docs/contribute/how-to-reproduce.md
+++ b/docs/contribute/how-to-reproduce.md
@@ -21,7 +21,7 @@ Make sure you have:
First, open a terminal and run the following command:
```shell
-npx sb@next repro
+npx storybook@next repro
```
diff --git a/docs/essentials/introduction.md b/docs/essentials/introduction.md
index bd2b6661e24d..78b3da7d1e38 100644
--- a/docs/essentials/introduction.md
+++ b/docs/essentials/introduction.md
@@ -14,7 +14,7 @@ A major strength of Storybook are [addons](https://storybook.js.org/addons) that
### Installation
-If you ran `sb init` to include Storybook in your project, the Essentials addon ([`@storybook/addon-essentials`](https://storybook.js.org/addons/tag/essentials)) is already installed and configured for you. You can skip the rest of this section.
+If you ran `storybook init` to include Storybook in your project, the Essentials addon ([`@storybook/addon-essentials`](https://storybook.js.org/addons/tag/essentials)) is already installed and configured for you. You can skip the rest of this section.
If you're upgrading from a previous Storybook version, you'll need to run the following command in your terminal:
diff --git a/docs/get-started/installation-problems/angular.mdx b/docs/get-started/installation-problems/angular.mdx
index c0c463e548bf..8113277199e3 100644
--- a/docs/get-started/installation-problems/angular.mdx
+++ b/docs/get-started/installation-problems/angular.mdx
@@ -1,20 +1,19 @@
-- Storybook's CLI provides support for both [Yarn](https://yarnpkg.com/) and [npm](https://www.npmjs.com/) package managers.
- If you have Yarn installed in your environment but prefer to use npm as your default package manager add the `--use-npm` flag to your installation command. For example:
+- Add the `--type angular` flag to the installation command to set up Storybook manually:
```shell
- npx storybook init --use-npm
+ npx storybook init --type angular
```
-- Add the `--type angular` flag to the installation command to set up Storybook manually:
+- Storybook's CLI provides support for both [Yarn](https://yarnpkg.com/) and [npm](https://www.npmjs.com/) package managers. If you have Yarn installed in your environment but prefer to use npm as your default package manager add the `--use-npm` flag to your installation command. For example:
```shell
- npx sb init --type angular
+ npx storybook init --use-npm
```
- Storybook supports Webpack 5 out of the box. If you're upgrading from a previous version, run the following command to enable it:
```shell
- npx sb@next automigrate
+ npx storybook@next automigrate
```
Check the [Migration Guide](https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#automigrate) for more information on how to set up Webpack 5.
@@ -26,7 +25,7 @@
- If you need further customization to the Storybook builder configuration, you can use the following table as a reference:
| Configuration element | Description |
-|------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
+| ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `"browserTarget"` | Build target to be served using the following format. `"example-project:builder:config"` |
| `"tsConfig"` | Location of the TypeScript configuration file, relative to the current workspace. `"tsConfig": "./tsconfig.json"`. |
| `"port"` | Port used by Storybook. `"port": 6006` |
diff --git a/docs/get-started/installation-problems/ember.mdx b/docs/get-started/installation-problems/ember.mdx
index 7a7698e3d84b..04920a346755 100644
--- a/docs/get-started/installation-problems/ember.mdx
+++ b/docs/get-started/installation-problems/ember.mdx
@@ -1,14 +1,7 @@
-- Storybook's CLI provides support for both [Yarn](https://yarnpkg.com/) and [npm](https://www.npmjs.com/) package managers.
- If you have Yarn installed in your environment but prefer to use npm as your default package manager add the `--use-npm` flag to your installation command. For example:
-
- ```shell
- npx storybook init --use-npm
- ```
-
- Add the `--type ember` flag to the installation command to set up Storybook manually:
```shell
- npx sb init --type ember
+ npx storybook init --type ember
```
- During the install process, if you get the following warning message:
@@ -21,4 +14,10 @@
Update the [`@storybook/ember-cli-storybook`](https://www.npmjs.com/package/@storybook/ember-cli-storybook) package to the latest version to fix it.
+- Storybook's CLI provides support for both [Yarn](https://yarnpkg.com/) and [npm](https://www.npmjs.com/) package managers. If you have Yarn installed in your environment but prefer to use npm as your default package manager add the `--use-npm` flag to your installation command. For example:
+
+ ```shell
+ npx storybook init --use-npm
+ ```
+
- For other installation issues, check the [Ember README](../../app/ember/README.md) for additional instructions.
\ No newline at end of file
diff --git a/docs/get-started/installation-problems/html.mdx b/docs/get-started/installation-problems/html.mdx
index d03ae5eb9385..8bd4eae77abe 100644
--- a/docs/get-started/installation-problems/html.mdx
+++ b/docs/get-started/installation-problems/html.mdx
@@ -1,7 +1,7 @@
- Add the `--type html` flag to the installation command to set up Storybook manually:
```shell
- npx sb init --type html
+ npx storybook init --type html
```
- For other installation issues, check the [Html README](../../app/html/README.md) for additional instructions.
\ No newline at end of file
diff --git a/docs/get-started/installation-problems/preact.mdx b/docs/get-started/installation-problems/preact.mdx
index 593f0c13ef33..d3c98c8a2f38 100644
--- a/docs/get-started/installation-problems/preact.mdx
+++ b/docs/get-started/installation-problems/preact.mdx
@@ -1,14 +1,13 @@
-- Storybook's CLI provides support for both [Yarn](https://yarnpkg.com/) and [npm](https://www.npmjs.com/) package managers.
- If you have Yarn installed in your environment but prefer to use npm as your default package manager add the `--use-npm` flag to your installation command. For example:
+- Add the `--type preact` flag to the installation command to set up Storybook manually:
```shell
- npx storybook init --use-npm
+ npx storybook init --type preact
```
-
-- Add the `--type preact` flag to the installation command to set up Storybook manually:
+
+ - Storybook's CLI provides support for both [Yarn](https://yarnpkg.com/) and [npm](https://www.npmjs.com/) package managers. If you have Yarn installed in your environment but prefer to use npm as your default package manager add the `--use-npm` flag to your installation command. For example:
```shell
- npx sb init --type preact
+ npx storybook init --use-npm
```
- For other installation issues, check the [Preact README](../../app/preact/README.md) for additional instructions.
\ No newline at end of file
diff --git a/docs/get-started/installation-problems/react.mdx b/docs/get-started/installation-problems/react.mdx
index 0acc6ef29f97..6f2853b02b41 100644
--- a/docs/get-started/installation-problems/react.mdx
+++ b/docs/get-started/installation-problems/react.mdx
@@ -1,20 +1,19 @@
-- Storybook's CLI provides support for both [Yarn](https://yarnpkg.com/) and [npm](https://www.npmjs.com/) package managers.
- If you have Yarn installed in your environment but prefer to use npm as your default package manager add the `--use-npm` flag to your installation command. For example:
-
+- Add the `--type react` flag to the installation command to set up Storybook manually:
+
```shell
- npx storybook init --use-npm
+ npx storybook init --type react
```
-- Add the `--type react` flag to the installation command to set up Storybook manually:
+ - Storybook's CLI provides support for both [Yarn](https://yarnpkg.com/) and [npm](https://www.npmjs.com/) package managers. If you have Yarn installed in your environment but prefer to use npm as your default package manager add the `--use-npm` flag to your installation command. For example:
```shell
- npx sb init --type react
+ npx storybook init --use-npm
```
- Storybook supports Webpack 5 out of the box. If you're upgrading from a previous version, run the following command to enable it:
```shell
- npx sb@next automigrate
+ npx storybook@next automigrate
```
Check the [Migration Guide](https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#cra5-upgrade) for more information on how to set up Webpack 5.
diff --git a/docs/get-started/installation-problems/svelte.mdx b/docs/get-started/installation-problems/svelte.mdx
index 68f248b11ec8..0fa6d9782b37 100644
--- a/docs/get-started/installation-problems/svelte.mdx
+++ b/docs/get-started/installation-problems/svelte.mdx
@@ -1,14 +1,13 @@
-- Storybook's CLI provides support for both [Yarn](https://yarnpkg.com/) and [npm](https://www.npmjs.com/) package managers.
- If you have Yarn installed in your environment but prefer to use npm as your default package manager add the `--use-npm` flag to your installation command. For example:
-
+- Add the `--type svelte` flag to the installation command to set up Storybook manually:
+
```shell
- npx storybook init --use-npm
+ npx storybook init --type svelte
```
-
-- Add the `--type svelte` flag to the installation command to set up Storybook manually:
+
+ - Storybook's CLI provides support for both [Yarn](https://yarnpkg.com/) and [npm](https://www.npmjs.com/) package managers. If you have Yarn installed in your environment but prefer to use npm as your default package manager add the `--use-npm` flag to your installation command. For example:
```shell
- npx sb init --type svelte
+ npx storybook init --use-npm
```
- For issues with Svelte Native Story Format, check the [Svelte Story Format addon repository](https://github.com/storybookjs/addon-svelte-csf) for instructions.
diff --git a/docs/get-started/installation-problems/vue.mdx b/docs/get-started/installation-problems/vue.mdx
index d0c276ff4970..3caa0a56199e 100644
--- a/docs/get-started/installation-problems/vue.mdx
+++ b/docs/get-started/installation-problems/vue.mdx
@@ -1,18 +1,17 @@
-- Storybook's CLI provides support for both [Yarn](https://yarnpkg.com/) and [npm](https://www.npmjs.com/) package managers.
- If you have Yarn installed in your environment but prefer to use npm as your default package manager add the `--use-npm` flag to your installation command. For example:
-
- ```shell
- npx storybook init --use-npm
- ```
-
- Add the `--type vue` (for Vue 2), or `--type vue3` (for Vue 3) flag to the installation command to set up Storybook manually:
```shell
# For Vue 2 projects
- npx sb init --type vue
+ npx storybook init --type vue
# For Vue 3 projects
- npx sb init --type vue3
+ npx storybook init --type vue3
+ ```
+
+ - Storybook's CLI provides support for both [Yarn](https://yarnpkg.com/) and [npm](https://www.npmjs.com/) package managers. If you have Yarn installed in your environment but prefer to use npm as your default package manager add the `--use-npm` flag to your installation command. For example:
+
+ ```shell
+ npx storybook init --use-npm
```
- For other installation issues, check the [Vue 2 README](../../app/vue/README.md), or the [Vue 3 README](../../app/vue3/README.md) for additional instructions.
diff --git a/docs/get-started/installation-problems/web-components.mdx b/docs/get-started/installation-problems/web-components.mdx
index 21098fcf6aad..09841ea19343 100644
--- a/docs/get-started/installation-problems/web-components.mdx
+++ b/docs/get-started/installation-problems/web-components.mdx
@@ -1,7 +1,7 @@
- Add the `--type web_components` flag to the installation command to set up Storybook manually:
```shell
- npx sb init --type web_components
+ npx storybook init --type web_components
```
- For other installation issues, check the [Web Components README](../../app/web-components/README.md) for additional instructions.
\ No newline at end of file
diff --git a/docs/sharing/storybook-composition.md b/docs/sharing/storybook-composition.md
index ba12b5276a9c..2ccb5570bc8b 100644
--- a/docs/sharing/storybook-composition.md
+++ b/docs/sharing/storybook-composition.md
@@ -74,12 +74,12 @@ You can also compose Storybooks based on the current development environment (e.
So far we've seen how we can use composition with local or published Storybooks. One thing worth mentioning as your Storybook will grow in time with your own stories, or through composition with other Storybooks, is that you can optimize the deployment process by including the following command in your workflow, run from your project root:
```shell
-npx sb extract
+npx storybook extract
```
-`sb extract` uses [Puppeteer](https://www.npmjs.com/package/puppeteer), which downloads and installs Chromium. Set the environment `SB_CHROMIUM_PATH` to configure your local Chromium installation.
+`storybook extract` uses [Puppeteer](https://www.npmjs.com/package/puppeteer), which downloads and installs Chromium. Set the environment `SB_CHROMIUM_PATH` to configure your local Chromium installation.
@@ -100,7 +100,7 @@ Linking to a Storybook deployed using this approach will yield all the stories a
If you need, you can also add additional arguments to this command. For instance, if you want to generate the stories.json file into a custom directory you can use the following:
```shell
-npx sb extract my-built-storybook-directory my-other-directory/stories.json
+npx storybook extract my-built-storybook-directory my-other-directory/stories.json
```
When executed it will lookup a built Storybook in the `my-built-storybook-directory` and create the `stories.json` file in the `my-other-directory` with all the necessary information.
diff --git a/docs/snippets/common/gizmo-story-controls-customization.js.mdx b/docs/snippets/common/gizmo-story-controls-customization.js.mdx
index 3bc936240afa..bf521438d404 100644
--- a/docs/snippets/common/gizmo-story-controls-customization.js.mdx
+++ b/docs/snippets/common/gizmo-story-controls-customization.js.mdx
@@ -52,7 +52,7 @@ export default {
meshColors: {
control: {
type: 'color',
- presetsColors: ['#ff0000', '#00ff00', '#0000ff'],
+ presetColors: ['#ff0000', '#00ff00', '#0000ff'],
},
},
revisionDate: {
diff --git a/docs/snippets/common/gizmo-story-controls-customization.mdx.mdx b/docs/snippets/common/gizmo-story-controls-customization.mdx.mdx
index 79959e089d55..55543dd93639 100644
--- a/docs/snippets/common/gizmo-story-controls-customization.mdx.mdx
+++ b/docs/snippets/common/gizmo-story-controls-customization.mdx.mdx
@@ -60,7 +60,7 @@ import { Gizmo } from './Gizmo';
meshColors: {
control: {
type: 'color',
- presetsColors: ['#ff0000', '#00ff00', '#0000ff'],
+ presetColors: ['#ff0000', '#00ff00', '#0000ff'],
},
},
revisionDate: {
diff --git a/docs/snippets/html/button-story-component-decorator.js.mdx b/docs/snippets/html/button-story-component-decorator.js.mdx
new file mode 100644
index 000000000000..c87cb62adbb8
--- /dev/null
+++ b/docs/snippets/html/button-story-component-decorator.js.mdx
@@ -0,0 +1,21 @@
+```js
+// Button.stories.js
+
+import { createButton } from './Button';
+
+export default {
+ /* π The title prop is optional.
+ * See https://storybook.js.org/docs/html/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
+ title: 'Button',
+ decorators: [(story) => {
+ const decorator = document.createElement('div');
+ decorator.style.margin = '3em';
+ decorator.appendChild(story());
+ return decorator;
+ }],
+};
+
+export const Primary = (args) => createButton(args);
+```
diff --git a/docs/snippets/html/button-story-component-decorator.ts.mdx b/docs/snippets/html/button-story-component-decorator.ts.mdx
new file mode 100644
index 000000000000..d1a4efaa4258
--- /dev/null
+++ b/docs/snippets/html/button-story-component-decorator.ts.mdx
@@ -0,0 +1,23 @@
+```ts
+// Button.stories.ts
+
+import { Meta, StoryFn } from '@storybook/html';
+
+import { createButton, ButtonArgs } from './Button';
+
+export default {
+ /* π The title prop is optional.
+ * See https://storybook.js.org/docs/html/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
+ title: 'Button',
+ decorators: [(story) => {
+ const decorator = document.createElement('div');
+ decorator.style.margin = '3em';
+ decorator.appendChild(story());
+ return decorator;
+ }],
+} as Meta;
+
+export const Primary: StoryFn = (args) => createButton(args);
+```
diff --git a/docs/snippets/html/button-story-default-exports.js.mdx b/docs/snippets/html/button-story-default-exports.js.mdx
new file mode 100644
index 000000000000..c6bbe5bf64f1
--- /dev/null
+++ b/docs/snippets/html/button-story-default-exports.js.mdx
@@ -0,0 +1,13 @@
+```js
+// Button.stories.js
+
+import { createButton } from './Button';
+
+export default {
+ /* π The title prop is optional.
+ * See https://storybook.js.org/docs/html/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
+ title: 'Button',
+};
+```
diff --git a/docs/snippets/html/button-story-default-exports.ts.mdx b/docs/snippets/html/button-story-default-exports.ts.mdx
new file mode 100644
index 000000000000..e294d98b1b40
--- /dev/null
+++ b/docs/snippets/html/button-story-default-exports.ts.mdx
@@ -0,0 +1,15 @@
+```ts
+// Button.stories.ts
+
+import { Meta } from '@storybook/html';
+
+import { createButton, ButtonArgs } from './Button';
+
+export default {
+ /* π The title prop is optional.
+ * See https://storybook.js.org/docs/html/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
+ title: 'Button',
+} as Meta;
+```
diff --git a/docs/snippets/html/button-story-rename-story.js.mdx b/docs/snippets/html/button-story-rename-story.js.mdx
new file mode 100644
index 000000000000..3f13f148ce43
--- /dev/null
+++ b/docs/snippets/html/button-story-rename-story.js.mdx
@@ -0,0 +1,16 @@
+```js
+// Button.stories.js
+
+import { createButton } from './Button';
+
+export default {
+ /* π The title prop is optional.
+ * See https://storybook.js.org/docs/html/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
+ title: 'Button',
+};
+
+export const Primary = (args) => createButton(args);
+Primary.storyName = 'I am the primary';
+```
diff --git a/docs/snippets/html/button-story-rename-story.ts.mdx b/docs/snippets/html/button-story-rename-story.ts.mdx
new file mode 100644
index 000000000000..0b37196b9a41
--- /dev/null
+++ b/docs/snippets/html/button-story-rename-story.ts.mdx
@@ -0,0 +1,18 @@
+```ts
+// Button.stories.ts
+
+import { Meta, StoryFn } from '@storybook/html';
+
+import { createButton, ButtonArgs } from './Button';
+
+export default {
+ /* π The title prop is optional.
+ * See https://storybook.js.org/docs/html/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
+ title: 'Button',
+} as Meta;
+
+export const Primary: StoryFn = (args) => createButton(args);
+Primary.storyName = 'I am the primary';
+```
diff --git a/docs/snippets/html/button-story-using-args.js.mdx b/docs/snippets/html/button-story-using-args.js.mdx
new file mode 100644
index 000000000000..9df04fd6e394
--- /dev/null
+++ b/docs/snippets/html/button-story-using-args.js.mdx
@@ -0,0 +1,26 @@
+```js
+// Button.stories.js
+
+import { createButton } from './Button';
+
+export default {
+ /* π The title prop is optional.
+ * See https://storybook.js.org/docs/html/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
+ title: 'Button',
+};
+
+//π We create a βtemplateβ of how args map to rendering
+const Template = (args) => createButton(args);
+
+//π Each story then reuses that template
+export const Primary = Template.bind({});
+Primary.args = { primary: true, label: 'Button' };
+
+export const Secondary = Template.bind({});
+Secondary.args = { ...Primary.args, label: 'ππππ―' };
+
+export const Tertiary = Template.bind({});
+Tertiary.args = { ...Primary.args, label: 'ππππ€' };
+```
diff --git a/docs/snippets/html/button-story-using-args.ts.mdx b/docs/snippets/html/button-story-using-args.ts.mdx
new file mode 100644
index 000000000000..759858bf1da4
--- /dev/null
+++ b/docs/snippets/html/button-story-using-args.ts.mdx
@@ -0,0 +1,27 @@
+```ts
+// Button.stories.ts
+
+import { Meta, StoryFn } from '@storybook/html';
+import { createButton, ButtonArgs } from './Button';
+
+export default {
+ /* π The title prop is optional.
+ * See https://storybook.js.org/docs/html/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
+ title: 'Button',
+} as Meta;
+
+//π We create a βtemplateβ of how args map to rendering
+const Template: StoryFn = (args): HTMLButtonElement => createButton(args);
+
+//π Each story then reuses that template
+export const Primary = Template.bind({});
+Primary.args = { primary: true, label: 'Button' };
+
+export const Secondary = Template.bind({});
+Secondary.args = { ...Primary.args, label: 'ππππ―' };
+
+export const Tertiary = Template.bind({});
+Tertiary.args = { ...Primary.args, label: 'ππππ€' };
+```
diff --git a/docs/snippets/html/button-story-with-args.js.mdx b/docs/snippets/html/button-story-with-args.js.mdx
index 60feb2014547..8d71b288cef9 100644
--- a/docs/snippets/html/button-story-with-args.js.mdx
+++ b/docs/snippets/html/button-story-with-args.js.mdx
@@ -1,4 +1,6 @@
```js
+// Button.stories.js
+
export default {
/* π The title prop is optional.
* See https://storybook.js.org/docs/html/configure/overview#configure-story-loading
diff --git a/docs/snippets/html/button-story-with-args.ts.mdx b/docs/snippets/html/button-story-with-args.ts.mdx
index 3130fc260de7..9b75446177ee 100644
--- a/docs/snippets/html/button-story-with-args.ts.mdx
+++ b/docs/snippets/html/button-story-with-args.ts.mdx
@@ -1,16 +1,23 @@
```ts
+// Button.stories.ts
+
import { Meta, StoryFn } from '@storybook/html';
+type ButtonArgs = {
+ primary: boolean;
+ label: string;
+}
+
export default {
/* π The title prop is optional.
* See https://storybook.js.org/docs/html/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'Button',
-} as Meta;
+} as Meta;
//π We create a βtemplateβ of how args map to rendering
-const Template: StoryFn = (args): HTMLButtonElement => {
+const Template: StoryFn = (args): HTMLButtonElement => {
const btn = document.createElement('button');
btn.innerText = args.label;
diff --git a/docs/snippets/html/button-story-with-blue-args.js.mdx b/docs/snippets/html/button-story-with-blue-args.js.mdx
new file mode 100644
index 000000000000..5cb8981ad168
--- /dev/null
+++ b/docs/snippets/html/button-story-with-blue-args.js.mdx
@@ -0,0 +1,25 @@
+```js
+// Button.stories.js
+
+import { createButton } from './Button';
+
+export default {
+ /* π The title prop is optional.
+ * See https://storybook.js.org/docs/html/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
+ title: 'Button',
+ //π Creates specific parameters for the story
+ parameters: {
+ backgrounds: {
+ values: [
+ { name: 'red', value: '#f00' },
+ { name: 'green', value: '#0f0' },
+ { name: 'blue', value: '#00f' },
+ ],
+ },
+ },
+};
+
+export const Primary = (args) => createButton(args);
+```
diff --git a/docs/snippets/html/button-story-with-blue-args.ts.mdx b/docs/snippets/html/button-story-with-blue-args.ts.mdx
new file mode 100644
index 000000000000..906845b4f472
--- /dev/null
+++ b/docs/snippets/html/button-story-with-blue-args.ts.mdx
@@ -0,0 +1,27 @@
+```ts
+// Button.stories.ts
+
+import { Meta, StoryFn } from '@storybook/html';
+
+import { createButton, ButtonArgs } from './Button';
+
+export default {
+ /* π The title prop is optional.
+ * See https://storybook.js.org/docs/html/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
+ title: 'Button',
+ //π Creates specific parameters for the story
+ parameters: {
+ backgrounds: {
+ values: [
+ { name: 'red', value: '#f00' },
+ { name: 'green', value: '#0f0' },
+ { name: 'blue', value: '#00f' },
+ ],
+ },
+ },
+} as Meta;
+
+export const Primary: StoryFn = (args) => createButton(args);
+```
diff --git a/docs/snippets/html/button-story-with-emojis.js.mdx b/docs/snippets/html/button-story-with-emojis.js.mdx
new file mode 100644
index 000000000000..b6b9b43ec295
--- /dev/null
+++ b/docs/snippets/html/button-story-with-emojis.js.mdx
@@ -0,0 +1,16 @@
+```js
+// Button.stories.js
+
+import { createButton } from './Button';
+
+export default {
+ /* π The title prop is optional.
+ * See https://storybook.js.org/docs/html/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
+ title: 'Button',
+};
+export const Primary = () => createButton({ backgroundColor: "#ff0", label: "Button"});
+export const Secondary = () => createButton({ backgroundColor: "#ff0", label: "ππππ―"});
+export const Tertiary = () => createButton({ backgroundColor: "#ff0", label: "ππππ€"});
+```
diff --git a/docs/snippets/html/button-story-with-emojis.ts.mdx b/docs/snippets/html/button-story-with-emojis.ts.mdx
new file mode 100644
index 000000000000..47a1f99f8ee1
--- /dev/null
+++ b/docs/snippets/html/button-story-with-emojis.ts.mdx
@@ -0,0 +1,17 @@
+```ts
+// Button.stories.ts
+
+import { Meta, StoryFn } from '@storybook/html';
+import { createButton, ButtonArgs } from './Button';
+
+export default {
+ /* π The title prop is optional.
+ * See https://storybook.js.org/docs/html/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
+ title: 'Button',
+} as Meta;
+export const Primary: StoryFn = () => createButton({ backgroundColor: "#ff0", label: "Button"});
+export const Secondary: StoryFn = () => createButton({ backgroundColor: "#ff0", label: "ππππ―"});
+export const Tertiary: StoryFn = () => createButton({ backgroundColor: "#ff0", label: "ππππ€"});
+```
diff --git a/docs/snippets/html/button-story.js.mdx b/docs/snippets/html/button-story.js.mdx
index 743c489eff80..6268687c428b 100644
--- a/docs/snippets/html/button-story.js.mdx
+++ b/docs/snippets/html/button-story.js.mdx
@@ -1,4 +1,6 @@
```js
+// Button.stories.js
+
export default {
/* π The title prop is optional.
* See https://storybook.js.org/docs/html/configure/overview#configure-story-loading
diff --git a/docs/snippets/html/button-story.ts.mdx b/docs/snippets/html/button-story.ts.mdx
index 104aa6ccbd19..62e72638171e 100644
--- a/docs/snippets/html/button-story.ts.mdx
+++ b/docs/snippets/html/button-story.ts.mdx
@@ -1,4 +1,6 @@
```ts
+// Button.stories.ts
+
import { Meta, StoryFn } from '@storybook/html';
export default {
diff --git a/docs/snippets/html/list-story-expanded.js.mdx b/docs/snippets/html/list-story-expanded.js.mdx
new file mode 100644
index 000000000000..b9cbe7d627f1
--- /dev/null
+++ b/docs/snippets/html/list-story-expanded.js.mdx
@@ -0,0 +1,27 @@
+
+```js
+// List.stories.js
+
+import { createList } from './List';
+import { createListItem } from './ListItem';
+
+export default {
+ title: 'List',
+};
+
+export const Empty = (args) => createList(args);
+
+export const OneItem = (args) => {
+ const list = createList(args);
+ list.appendChild(createListItem());
+ return list;
+};
+
+export const ManyItems = (args) => {
+ const list = createList(args);
+ list.appendChild(createListItem());
+ list.appendChild(createListItem());
+ list.appendChild(createListItem());
+ return list;
+};
+```
diff --git a/docs/snippets/html/list-story-expanded.ts.mdx b/docs/snippets/html/list-story-expanded.ts.mdx
new file mode 100644
index 000000000000..81e14d1162a4
--- /dev/null
+++ b/docs/snippets/html/list-story-expanded.ts.mdx
@@ -0,0 +1,29 @@
+
+```ts
+// List.stories.ts
+
+import { Meta, StoryFn } from '@storybook/html';
+
+import { createList, ListArgs } from './List';
+import { createListItem } from './ListItem';
+
+export default {
+ title: 'List',
+} as Meta;
+
+export const Empty: StoryFn = (args) => createList(args);
+
+export const OneItem: StoryFn = (args) => {
+ const list = createList(args);
+ list.appendChild(createListItem());
+ return list;
+};
+
+export const ManyItems: StoryFn = (args) => {
+ const list = createList(args);
+ list.appendChild(createListItem());
+ list.appendChild(createListItem());
+ list.appendChild(createListItem());
+ return list;
+};
+```
diff --git a/docs/snippets/html/list-story-reuse-data.js.mdx b/docs/snippets/html/list-story-reuse-data.js.mdx
new file mode 100644
index 000000000000..a58833617912
--- /dev/null
+++ b/docs/snippets/html/list-story-reuse-data.js.mdx
@@ -0,0 +1,22 @@
+
+```js
+// List.stories.js
+
+import { createList } from './List';
+import { createListItem } from './ListItem';
+
+// π We're importing the necessary stories from ListItem
+import { Selected, Unselected } from './ListItem.stories';
+
+export default {
+ title: 'List',
+};
+
+export const ManyItems = (args) => {
+ const list = createList(args);
+ list.appendChild(createListItem(Selected.args));
+ list.appendChild(createListItem(Unselected.args));
+ list.appendChild(createListItem(Unselected.args));
+ return list;
+};
+```
diff --git a/docs/snippets/html/list-story-reuse-data.ts.mdx b/docs/snippets/html/list-story-reuse-data.ts.mdx
new file mode 100644
index 000000000000..434bec00d690
--- /dev/null
+++ b/docs/snippets/html/list-story-reuse-data.ts.mdx
@@ -0,0 +1,32 @@
+
+```ts
+// List.stories.ts
+
+import { Meta, StoryFn } from '@storybook/html';
+
+import { createList, ListArgs } from './List';
+import { createListItem } from './ListItem';
+
+// π We're importing the necessary stories from ListItem
+import { Selected, Unselected } from './ListItem.stories';
+
+export default {
+ title: 'List',
+} as Meta;
+
+export const Empty: StoryFn = (args) => createList(args);
+
+export const OneItem: StoryFn = (args) => {
+ const list = createList(args);
+ list.appendChild(createListItem());
+ return list;
+};
+
+export const ManyItems: StoryFn = (args) => {
+ const list = createList(args);
+ list.appendChild(createListItem(Selected.args));
+ list.appendChild(createListItem(Unselected.args));
+ list.appendChild(createListItem(Unselected.args));
+ return list;
+};
+```
diff --git a/docs/snippets/html/list-story-starter.js.mdx b/docs/snippets/html/list-story-starter.js.mdx
new file mode 100644
index 000000000000..8e4959b468d3
--- /dev/null
+++ b/docs/snippets/html/list-story-starter.js.mdx
@@ -0,0 +1,12 @@
+```js
+// List.stories.js
+
+import { createList } from './List';
+
+export default {
+ title: 'List',
+};
+
+// Always an empty list, not super interesting
+const Template = (args) => createList(args);
+```
diff --git a/docs/snippets/html/list-story-starter.ts.mdx b/docs/snippets/html/list-story-starter.ts.mdx
new file mode 100644
index 000000000000..e0706e6c0827
--- /dev/null
+++ b/docs/snippets/html/list-story-starter.ts.mdx
@@ -0,0 +1,14 @@
+```ts
+// List.stories.ts
+
+import { Meta, StoryFn } from '@storybook/html';
+
+import { createList, ListArgs } from './List';
+
+export default {
+ title: 'List',
+} as Meta;
+
+// Always an empty list, not super interesting
+const Template: StoryFn = (args) => createList(args);
+```
diff --git a/docs/writing-stories/args.md b/docs/writing-stories/args.md
index b7b5ac95c273..6d10a8faab72 100644
--- a/docs/writing-stories/args.md
+++ b/docs/writing-stories/args.md
@@ -33,6 +33,8 @@ To define the args of a single story, use the `args` CSF story key:
'svelte/button-story-with-args.native-format.mdx',
'svelte/button-story-with-args.mdx.mdx',
'web-components/button-story-with-args.js.mdx',
+ 'html/button-story-with-args.ts.mdx',
+ 'html/button-story-with-args.js.mdx',
]}
/>
diff --git a/docs/writing-stories/introduction.md b/docs/writing-stories/introduction.md
index 96ca9925fffa..15e4c456516b 100644
--- a/docs/writing-stories/introduction.md
+++ b/docs/writing-stories/introduction.md
@@ -37,6 +37,8 @@ The _default_ export metadata controls how Storybook lists your stories and prov
'angular/button-story-default-export-with-component.ts.mdx',
'svelte/button-story-default-export-with-component.js.mdx',
'web-components/button-story-default-export-with-component.js.mdx',
+ 'html/button-story-default-export.js.mdx',
+ 'html/button-story-default-export.ts.mdx',
]}
/>
@@ -59,6 +61,8 @@ Use the _named_ exports of a CSF file to define your componentβs stories. We r
'svelte/button-story.js.mdx',
'svelte/button-story.native-format.mdx',
'web-components/button-story.js.mdx',
+ 'html/button-story.js.mdx',
+ 'html/button-story.ts.mdx',
]}
/>
@@ -99,6 +103,8 @@ You can rename any particular story you need. For instance, to give it a more ac
'angular/button-story-rename-story.ts.mdx',
'svelte/button-story-rename-story.js.mdx',
'web-components/button-story-rename-story.js.mdx',
+ 'html/button-story-rename-story.js.mdx',
+ 'html/button-story-rename-story.ts.mdx',
]}
/>
@@ -127,6 +133,8 @@ A story is a function that describes how to render a component. You can have mul
'svelte/button-story-with-emojis.native-format.mdx',
'svelte/button-story-with-emojis.mdx.mdx',
'web-components/button-story-with-emojis.js.mdx',
+ 'html/button-story-with-emojis.js.mdx',
+ 'html/button-story-with-emojis.ts.mdx',
]}
/>
@@ -152,6 +160,8 @@ Refine this pattern by introducing `args` for your component's stories. It reduc
'svelte/button-story-using-args.js.mdx',
'svelte/button-story-using-args.native-format.mdx',
'web-components/button-story-using-args.js.mdx',
+ 'html/button-story-using-args.js.mdx',
+ 'html/button-story-using-args.ts.mdx',
]}
/>
@@ -254,6 +264,8 @@ For instance, suppose you wanted to test your Button component against a differe
'svelte/button-story-with-blue-args.native-format.mdx',
'svelte/button-story-with-blue-args.mdx.mdx',
'web-components/button-story-with-blue-args.js.mdx',
+ 'html/button-story-with-blue-args.js.mdx',
+ 'html/button-story-with-blue-args.ts.mdx',
]}
/>
@@ -286,6 +298,8 @@ A simple example is adding padding to a componentβs stories. Accomplish this u
'svelte/button-story-component-decorator.native-format.mdx',
'svelte/button-story-component-decorator.mdx.mdx',
'web-components/button-story-component-decorator.js.mdx',
+ 'html/button-story-component-decorator.js.mdx',
+ 'html/button-story-component-decorator.ts.mdx',
]}
/>
@@ -310,6 +324,8 @@ When building design systems or component libraries, you may have two or more co
'vue/list-story-starter.ts-3.ts.mdx',
'svelte/list-story-starter.native-format.mdx',
'web-components/list-story-starter.js.mdx',
+ 'html/list-story-starter.js.mdx',
+ 'html/list-story-starter.ts.mdx',
]}
/>
@@ -330,6 +346,8 @@ In such cases, it makes sense to render a different function for each story:
'vue/list-story-expanded.ts-3.ts.mdx',
'svelte/list-story-expanded.native-format.mdx',
'web-components/list-story-expanded.js.mdx',
+ 'html/list-story-expanded.js.mdx',
+ 'html/list-story-expanded.ts.mdx',
]}
/>
@@ -349,6 +367,8 @@ You can also reuse stories from the child `ListItem` in your `List` component. T
'vue/list-story-reuse-data.3.js.mdx',
'vue/list-story-reuse-data.ts-3.ts.mdx',
'web-components/list-story-reuse-data.js.mdx',
+ 'html/list-story-reuse-data.js.mdx',
+ 'html/list-story-reuse-data.ts.mdx',
]}
/>
diff --git a/examples/official-storybook/stories/addon-controls.stories.tsx b/examples/official-storybook/stories/addon-controls.stories.tsx
index 6dea53b8f168..94f29aa214ad 100644
--- a/examples/official-storybook/stories/addon-controls.stories.tsx
+++ b/examples/official-storybook/stories/addon-controls.stories.tsx
@@ -6,7 +6,7 @@ export default {
component: Button,
argTypes: {
children: { control: 'text', name: 'Children', mapping: { basic: 'BASIC' } },
- type: { control: 'text', name: 'Type' },
+ type: { name: 'Type', control: { type: 'text', maxLength: 32 } },
json: { control: 'object', name: 'JSON' },
imageUrls: { control: { type: 'file', accept: '.png' }, name: 'Image Urls' },
label: {
@@ -71,8 +71,10 @@ export default {
const DEFAULT_NESTED_OBJECT = { a: 4, b: { c: 'hello', d: [1, 2, 3] } };
const Template = (args) => (
-