storybook/docs/snippets/vue/my-component-story-basic-and-props.ts.mdx
2023-01-06 19:15:31 +00:00

40 lines
1.0 KiB
Plaintext

```ts
// MyComponent.stories.ts
// For Vue 3 use import type { Meta, StoryObj } from '@storybook/vue3';
import type { Meta, StoryObj } from '@storybook/vue';
import MyComponent from './MyComponent.vue';
const meta: Meta<typeof MyComponent> = {
/* 👇 The title prop is optional.
* See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'Path/To/MyComponent',
component: MyComponent,
};
export default meta;
type Story = StoryObj<typeof MyComponent>;
/*
*👇 Render functions are a framework specific feature to allow you control on how the component renders.
* See https://storybook.js.org/docs/7.0/vue/api/csf
* to learn how to use render functions.
*/
export const Basic: Story = {
render: () => ({
components: { MyComponent },
template: '<MyComponent />',
}),
};
export const WithProp: Story = {
render: () => ({
components: { MyComponent },
template: '<MyComponent prop="value"/>',
}),
};
```