Storybook Vue 2.x renderer that enables Vue 2.x component story development and documentation (Note: @storybook/vue3 is separate)
npx @tessl/cli install tessl/npm-storybook--vue@7.6.0Storybook Vue renderer enables Vue 2.x component story development and documentation within the Storybook ecosystem. It provides a complete rendering engine that understands Vue's component system, reactivity model, and template syntax, allowing developers to create interactive component stories with full access to Vue features including props, events, slots, and computed properties.
npm install @storybook/vueimport type { Meta, StoryFn, StoryObj, Decorator, Loader } from "@storybook/vue";For story configuration:
import { storiesOf, configure, forceReRender, raw } from "@storybook/vue";For custom rendering:
import { render, renderToCanvas } from "@storybook/vue";import type { Meta, StoryObj } from "@storybook/vue";
import MyButton from "./MyButton.vue";
// Component metadata
const meta: Meta<typeof MyButton> = {
title: "Example/Button",
component: MyButton,
parameters: {
layout: "centered",
},
argTypes: {
backgroundColor: { control: "color" },
},
};
export default meta;
type Story = StoryObj<typeof meta>;
// Story definitions
export const Primary: Story = {
args: {
primary: true,
label: "Button",
},
};
export const Secondary: Story = {
args: {
label: "Button",
},
};The Storybook Vue renderer is built around several key components:
Complete TypeScript support for defining Vue component stories with full type safety and IntelliSense support.
type Meta<TCmpOrArgs = Args> = ComponentAnnotations<VueRenderer, ComponentPropsOrProps<TCmpOrArgs>>;
type StoryFn<TCmpOrArgs = Args> = AnnotatedStoryFn<VueRenderer, ComponentPropsOrProps<TCmpOrArgs>>;
type StoryObj<TMetaOrCmpOrArgs = Args> = StoryAnnotations<VueRenderer, ComponentPropsOrProps<TMetaOrCmpOrArgs>>;Legacy story APIs for backwards compatibility with older Storybook versions and migration scenarios.
function storiesOf(kind: string, module: NodeModule): StoryApi;
function configure(loader: Addon_Loadable, module: NodeModule): void;
function forceReRender(): void;
function raw(): any;Core rendering functionality that handles Vue component mounting, lifecycle management, and DOM integration.
function render(args: Args, context: StoryContext): VueRenderer['storyResult'];
function renderToCanvas(renderContext: RenderContext<VueRenderer>, canvasElement: VueRenderer['canvasElement']): void;Story decoration system for wrapping Vue components with additional context, providers, or styling.
type Decorator<TArgs = StrictArgs> = DecoratorFunction<VueRenderer, TArgs>;
function decorateStory(storyFn: LegacyStoryFn<VueRenderer>, decorators: DecoratorFunction<VueRenderer>[]): LegacyStoryFn<VueRenderer>;Automatic documentation generation including component prop extraction, source code generation, and argument type inference.
function extractArgTypes(component: VueRenderer['component']): StrictArgTypes | null;
function sourceDecorator(storyFn: any, context: StoryContext): ComponentOptions<Vue>;interface VueRenderer extends WebRenderer {
component: Component<any, any, any, any> | AsyncComponent<any, any, any, any>;
storyResult: StoryFnVueReturnType;
}
type StoryFnVueReturnType = Component<any, any, any, any> | AsyncComponent<any, any, any, any>;
type StoryContext<TArgs = StrictArgs> = GenericStoryContext<VueRenderer, TArgs>;type Loader<TArgs = StrictArgs> = LoaderFunction<VueRenderer, TArgs>;
type Preview = ProjectAnnotations<VueRenderer>;
interface ShowErrorArgs {
title: string;
description: string;
}