mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-09 00:19:13 +08:00
27 lines
544 B
Plaintext
27 lines
544 B
Plaintext
```tsx
|
|
// List.stories.ts|tsx
|
|
import React from 'react';
|
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
|
|
import { List } from './List';
|
|
import { ListItem } from './ListItem';
|
|
|
|
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 = {};
|
|
|
|
export const OneItem: Story = {
|
|
render: (args) => (
|
|
<List {...args}>
|
|
<ListItem />
|
|
</List>
|
|
),
|
|
};
|
|
```
|