storybook/docs/snippets/react/my-component-story-configure-viewports.ts.mdx
2022-11-17 16:32:02 +01:00

39 lines
919 B
Plaintext

```tsx
// MyComponent.stories.ts|tsx
import type { Meta, StoryObj } from '@storybook/react';
import { INITIAL_VIEWPORTS } from '@storybook/addon-viewport';
import { MyComponent } from './MyComponent';
const meta: Meta<typeof MyComponent> = {
/* 👇 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: 'MyComponent',
component: MyComponent,
parameters: {
//👇 The viewports object from the Essentials addon
viewport: {
//👇 The viewports you want to use
viewports: INITIAL_VIEWPORTS,
//👇 Your own default viewport
defaultViewport: 'iphone6',
},
},
};
export default meta;
type Story = StoryObj<typeof MyComponent>;
export const MyStory: Story = {
parameters: {
viewport: {
defaultViewport: 'iphonex',
},
},
};
```