storybook/docs/snippets/vue/list-story-with-sub-components.ts-4-9.mdx
2024-01-30 10:20:01 -07:00

33 lines
674 B
Plaintext

```ts
// List.stories.ts
import type { Meta, StoryObj } from '@storybook/vue3';
import List from './List.vue';
import ListItem from './ListItem.vue';
const meta = {
component: List,
subcomponents: { ListItem }, //👈 Adds the ListItem component as a subcomponent
} satisfies Meta<typeof List>;
export default meta;
type Story = StoryObj<typeof meta>;
export const Empty: Story = {
render: () => ({
components: { List },
template: '<List />',
}),
};
export const OneItem: Story = {
render: (args) => ({
components: { List, ListItem },
setup() {
return { args }
}
template: '<List v-bind="args"><ListItem /></List>',
}),
};
```