How to write stories? โ
Create a Vue file ending in .story.vue and put <Story> at the root of its template.
<!-- Meow.story.vue -->
<template>
<Story>
๐ฑ
</Story>
</template>Set the optional title prop to name the story in the workbench.
<template>
<Story title="๐ฑ Meow">
๐ฑ
</Story>
</template>Import components and add styles as you would in any Vue file.
<!-- Meow.story.vue -->
<script setup>
import Meow from './Meow.vue'
</script>
<template>
<Story>
<Meow />
</Story>
</template>Variants โ
Use variants to show different states or use cases. Add each variant with the <Variant> tag. Give each variant a readable title, such as โDisabledโ.
<template>
<Story title="Cars">
<Variant title="default">
๐
</Variant>
<Variant title="Fast">
๐๏ธ
</Variant>
<Variant title="Slow">
๐
</Variant>
</Story>
</template>Layout โ
Set the storyโs layout.type to choose how its variants appear. For stories without an explicit layout, Histoire uses your local or project default, which falls back to Grid. A view in the URL or a remembered view can override the story layout.
Single layout โ
Use type: "single" to display one variant at a time. The variant runs in an iframe so CSS media queries use its own viewport.
Stories always render inside an iframe. Remove the iframe option when migrating. The story iframe owns live state. See state ownership during migration.
<template>
<Story
title="Cars"
:layout="{ type: 'single' }"
>
<Variant title="default">
๐
</Variant>
<Variant title="Fast">
๐๏ธ
</Variant>
<Variant title="Slow">
๐
</Variant>
</Story>
</template>Grid layout โ
Use type: "grid" to compare variants side by side.
<template>
<Story
title="Cars"
:layout="{ type: 'grid' }"
>
<Variant title="default">
๐
</Variant>
<Variant title="Fast">
๐๏ธ
</Variant>
<Variant title="Slow">
๐
</Variant>
</Story>
</template>