storybook/docs/snippets/react/list-story-with-subcomponents.ts-4-9.mdx
Kasper Peulen 7452663a26 Prettyyy
2023-01-17 08:10:49 +01:00

35 lines
722 B
Plaintext

```tsx
// List.stories.ts|tsx
import type { Meta, StoryObj } from '@storybook/react';
import { List } from './List';
import { ListItem } from './ListItem';
const meta = {
/* 👇 The title prop is optional.
* See https://storybook.js.org/docs/7.0/react/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'List',
component: List,
//👈 Adds the ListItem component as a subcomponent
subcomponents: { ListItem },
} satisfies Meta<typeof List>;
export default meta;
type Story = StoryObj<typeof meta>;
export const Empty: Story = {};
export const OneItem: Story = {
render: (args) => (
<List {...args}>
<ListItem />
</List>
),
};
```