storybook/docs/snippets/react/list-story-with-subcomponents.ts.mdx
2021-11-04 23:10:45 +00:00

29 lines
794 B
Plaintext

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