What is @storybook/vue?
@storybook/vue is a tool for developing UI components in isolation for Vue.js applications. It allows developers to build, test, and document components independently, which can improve the development workflow and ensure components are well-tested and documented.
What are @storybook/vue's main functionalities?
Component Development
Allows developers to create and display different states of Vue components in isolation. This helps in visualizing and testing components independently.
import { storiesOf } from '@storybook/vue';
import MyButton from './MyButton.vue';
storiesOf('MyButton', module)
.add('default', () => ({
components: { MyButton },
template: '<my-button>Default</my-button>'
}))
.add('with emoji', () => ({
components: { MyButton },
template: '<my-button>😀 😎 👍 💯</my-button>'
}));
Addons
Supports various addons to enhance the development experience, such as knobs for dynamic prop editing, actions for event handling, and more.
import { withKnobs, text } from '@storybook/addon-knobs';
import MyButton from './MyButton.vue';
export default {
title: 'MyButton',
decorators: [withKnobs],
};
export const withText = () => ({
components: { MyButton },
props: {
buttonText: {
default: text('Button Text', 'Hello Storybook'),
},
},
template: '<my-button :text="buttonText" />',
});
Documentation
Enables the creation of interactive documentation for components, making it easier for other developers to understand and use them.
import { Meta, Story } from '@storybook/vue';
import MyButton from './MyButton.vue';
export default {
title: 'MyButton',
component: MyButton,
} as Meta;
const Template: Story = (args, { argTypes }) => ({
props: Object.keys(argTypes),
components: { MyButton },
template: '<my-button v-bind="$props" />',
});
export const Primary = Template.bind({});
Primary.args = {
primary: true,
label: 'Button',
};
Other packages similar to @storybook/vue
vue-styleguidist
Vue Styleguidist is a tool for creating style guides for Vue components. It focuses on documenting components and their usage, similar to Storybook, but with a stronger emphasis on style guide generation.
docz
Docz is a documentation tool that supports multiple frameworks, including Vue. It allows developers to create interactive documentation for their components, similar to Storybook, but with a broader focus on documentation rather than just component development.
vue-play
Vue Play is a minimalistic library for developing Vue components in isolation. It provides a simpler and more lightweight alternative to Storybook, focusing on the core functionality of component isolation and testing.
Storybook for Vue
![codecov](https://codecov.io/gh/storybooks/storybook/branch/master/graph/badge.svg)
![Sponsors on Open Collective](https://opencollective.com/storybook/sponsors/badge.svg)
Storybook for Vue is a UI development environment for your Vue components.
With it, you can visualize different states of your UI components and develop them interactively.
![Storybook Screenshot](https://github.com/storybooks/storybook/blob/master/app/vue/docs/demo.gif)
Storybook runs outside of your app.
So you can develop UI components in isolation without worrying about app specific dependencies and requirements.
Getting Started
npm i -g @storybook/cli
cd my-vue-app
getstorybook
For more information visit: storybook.js.org
Starter Storybook-for-Vue Boilerplate project with Vuetify Material Component Framework
https://github.com/white-rabbit-japan/vuetify-storyboard-boilerplate
Storybook also comes with a lot of addons and a great API to customize as you wish.
You can also build a static version of your storybook and deploy it anywhere you want.
Vue Notes
- When using global custom components or extension (e.g
Vue.use
). You will need to declare those in the ./storybook/config.js
.