Back to Storybook

Button Story Component Args Primary

docs/_snippets/button-story-component-args-primary.md

10.3.68.3 KB
Original Source
ts
import type { Meta } from '@storybook/angular';

import { Button } from './button.component';

const meta: Meta<Button> = {
  component: Button,
  //๐Ÿ‘‡ Creates specific argTypes
  argTypes: {
    backgroundColor: { control: 'color' },
  },
  args: {
    //๐Ÿ‘‡ Now all Button stories will be primary.
    primary: true,
  },
};

export default meta;
ts
import preview from '../.storybook/preview';

import { Button } from './button.component';

const meta = preview.meta({
  component: Button,
  //๐Ÿ‘‡ Creates specific argTypes
  argTypes: {
    backgroundColor: { control: 'color' },
  },
  args: {
    //๐Ÿ‘‡ Now all Button stories will be primary.
    primary: true,
  },
});
js
import { Button } from './Button';

export default {
  component: Button,
  //๐Ÿ‘‡ Creates specific argTypes
  argTypes: {
    backgroundColor: { control: 'color' },
  },
  args: {
    //๐Ÿ‘‡ Now all Button stories will be primary.
    primary: true,
  },
};
ts
// Replace your-framework with the framework you are using, e.g. react-vite, nextjs, nextjs-vite, etc.
import type { Meta } from '@storybook/your-framework';

import { Button } from './Button';

const meta = {
  component: Button,
  //๐Ÿ‘‡ Creates specific argTypes
  argTypes: {
    backgroundColor: { control: 'color' },
  },
  args: {
    //๐Ÿ‘‡ Now all Button stories will be primary.
    primary: true,
  },
} satisfies Meta<typeof Button>;

export default meta;
js
import { Button } from './Button';

export default {
  component: Button,
  //๐Ÿ‘‡ Creates specific argTypes
  argTypes: {
    backgroundColor: { control: 'color' },
  },
  args: {
    //๐Ÿ‘‡ Now all Button stories will be primary.
    primary: true,
  },
};
tsx
import type { Meta } from 'storybook-solidjs-vite';

import { Button } from './Button';

const meta = {
  component: Button,
  //๐Ÿ‘‡ Creates specific argTypes
  argTypes: {
    backgroundColor: { control: 'color' },
  },
  args: {
    //๐Ÿ‘‡ Now all Button stories will be primary.
    primary: true,
  },
} satisfies Meta<typeof Button>;

export default meta;
svelte
<script module>
  import { defineMeta } from '@storybook/addon-svelte-csf';

  import Button from './Button.svelte';

  const { Story } = defineMeta({
    component: Button,
    //๐Ÿ‘‡ Creates specific argTypes
    argTypes: {
      backgroundColor: { control: 'color' },
    },
    args: {
      //๐Ÿ‘‡ Now all Button stories will be primary.
      primary: true,
    },
  });
</script>
js
import Button from './Button.svelte';

export default {
  component: Button,
  //๐Ÿ‘‡ Creates specific argTypes
  argTypes: {
    backgroundColor: { control: 'color' },
  },
  args: {
    //๐Ÿ‘‡ Now all Button stories will be primary.
    primary: true,
  },
};
svelte
<script module>
  import { defineMeta } from '@storybook/addon-svelte-csf';

  import Button from './Button.svelte';

  const { Story } = defineMeta({
    component: Button,
    //๐Ÿ‘‡ Creates specific argTypes
    argTypes: {
      backgroundColor: { control: 'color' },
    },
    args: {
      //๐Ÿ‘‡ Now all Button stories will be primary.
      primary: true,
    },
  });
</script>
ts
// Replace your-framework with svelte-vite or sveltekit
import type { Meta } from '@storybook/your-framework';

import Button from './Button.svelte';

const meta = {
  component: Button,
  //๐Ÿ‘‡ Creates specific argTypes
  argTypes: {
    backgroundColor: { control: 'color' },
  },
  args: {
    //๐Ÿ‘‡ Now all Button stories will be primary.
    primary: true,
  },
} satisfies Meta<typeof Button>;

export default meta;
js
import Button from './Button.vue';

export default {
  component: Button,
  //๐Ÿ‘‡ Creates specific argTypes
  argTypes: {
    backgroundColor: { control: 'color' },
  },
  args: {
    //๐Ÿ‘‡ Now all Button stories will be primary.
    primary: true,
  },
};
ts
import type { Meta } from '@storybook/vue3-vite';

import Button from './Button.vue';

const meta = {
  component: Button,
  //๐Ÿ‘‡ Creates specific argTypes
  argTypes: {
    backgroundColor: { control: 'color' },
  },
  args: {
    //๐Ÿ‘‡ Now all Button stories will be primary.
    primary: true,
  },
} satisfies Meta<typeof Button>;

export default meta;
ts
import preview from '../.storybook/preview';

import Button from './Button.vue';

const meta = preview.meta({
  component: Button,
  //๐Ÿ‘‡ Creates specific argTypes
  argTypes: {
    backgroundColor: { control: 'color' },
  },
  args: {
    //๐Ÿ‘‡ Now all Button stories will be primary.
    primary: true,
  },
});
<!-- JS snippets still needed while providing both CSF 3 & Next -->
js
import preview from '../.storybook/preview';

import Button from './Button.vue';

const meta = preview.meta({
  component: Button,
  //๐Ÿ‘‡ Creates specific argTypes
  argTypes: {
    backgroundColor: { control: 'color' },
  },
  args: {
    //๐Ÿ‘‡ Now all Button stories will be primary.
    primary: true,
  },
});
js
export default {
  component: 'demo-button',
  // ๐Ÿ‘‡ Creates specific argTypes
  argTypes: {
    backgroundColor: { control: 'color' },
  },
  args: {
    // ๐Ÿ‘‡ Now all Button stories will be primary.
    primary: true,
  },
};
ts
import type { Meta, StoryObj } from '@storybook/web-components-vite';

const meta: Meta = {
  component: 'demo-button',
  // ๐Ÿ‘‡ Creates specific argTypes
  argTypes: {
    backgroundColor: { control: 'color' },
  },
  args: {
    // ๐Ÿ‘‡ Now all Button stories will be primary.
    primary: true,
  },
};

export default meta;
js
import preview from '../.storybook/preview';

const meta = preview.meta({
  component: 'demo-button',
  // ๐Ÿ‘‡ Creates specific argTypes
  argTypes: {
    backgroundColor: { control: 'color' },
  },
  args: {
    // ๐Ÿ‘‡ Now all Button stories will be primary.
    primary: true,
  },
});
ts
import preview from '../.storybook/preview';

const meta = preview.meta({
  component: 'demo-button',
  // ๐Ÿ‘‡ Creates specific argTypes
  argTypes: {
    backgroundColor: { control: 'color' },
  },
  args: {
    // ๐Ÿ‘‡ Now all Button stories will be primary.
    primary: true,
  },
});
ts
import preview from '../.storybook/preview';

import { Button } from './Button';

const meta = preview.meta({
  component: Button,
  //๐Ÿ‘‡ Creates specific argTypes
  argTypes: {
    backgroundColor: { control: 'color' },
  },
  args: {
    //๐Ÿ‘‡ Now all Button stories will be primary.
    primary: true,
  },
});
<!-- JS snippets still needed while providing both CSF 3 & Next -->
js
import preview from '../.storybook/preview';

import { Button } from './Button';

const meta = preview.meta({
  component: Button,
  //๐Ÿ‘‡ Creates specific argTypes
  argTypes: {
    backgroundColor: { control: 'color' },
  },
  args: {
    //๐Ÿ‘‡ Now all Button stories will be primary.
    primary: true,
  },
});