Vite
Configure Fumadocs Story for Vite-based frameworks.
Installation
npm i @fumadocs/storyAdd the Tailwind CSS preset.
@import '@fumadocs/story/css/preset.css';Add the Vite plugin:
import { defineConfig } from 'vite';
import story from '@fumadocs/story/vite';
export default defineConfig({
plugins: [story()],
});Create a Story
Create a story factory to store your global settings:
import { defineStoryFactory } from '@fumadocs/story/vite/client';
export const { defineStory } = defineStoryFactory();Now create your first story:
import { defineStory } from '@/lib/story';
import { MyComponent } from './my-component';
export const story = defineStory({
Component: MyComponent,
args: {
// default props (recommended)
initial: {},
},
});The .story suffix is required
The Vite plugin will only transform files matching *.story.{js,jsx,ts,tsx}, you can also configure filters from the Vite plugin.
Render a Story
Now you can render the story like:
import { story } from '@/components/my-component.story';
<story.WithControl />How is this guide?
Last updated on
