docs/_snippets/button-story-onclick-action-spy.md
import type { Meta, StoryObj } from '@storybook/angular';
import { fn } from 'storybook/test';
import { Button } from './button.component';
const meta: Meta<Button> = {
component: Button,
// ๐ Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked
args: { onClick: fn() },
};
export default meta;
import { fn } from 'storybook/test';
import preview from '../.storybook/preview';
import { Button } from './button.component';
const meta = preview.meta({
component: Button,
// ๐ Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked
args: { onClick: fn() },
});
<script module>
import { defineMeta } from '@storybook/addon-svelte-csf';
import { fn } from 'storybook/test';
import Button from './Button.svelte';
const { Story } = defineMeta({
component: Button,
// ๐ Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked
args: { onClick: fn() },
});
</script>
import { fn } from 'storybook/test';
import Button from './Button.svelte';
export default {
component: Button,
// ๐ Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked
args: { onClick: fn() },
};
import { fn } from 'storybook/test';
import { Button } from './Button';
export default {
component: Button,
// ๐ Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked
args: { onClick: fn() },
};
<script module>
import { defineMeta } from '@storybook/addon-svelte-csf';
import { fn } from 'storybook/test';
import Button from './Button.svelte';
const { Story } = defineMeta({
component: Button,
// ๐ Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked
args: { onClick: fn() },
});
</script>
// Replace your-framework with svelte-vite or sveltekit
import type { Meta } from '@storybook/your-framework';
import { fn } from 'storybook/test';
import Button from './Button.svelte';
const meta = {
component: Button,
// ๐ Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked
args: { onClick: fn() },
} satisfies Meta<typeof Button>;
export default meta;
// Replace your-framework with the framework you are using, e.g. react-vite, nextjs, vue3-vite, etc.
import type { Meta } from '@storybook/your-framework';
import { fn } from 'storybook/test';
import { Button } from './Button';
const meta = {
component: Button,
// ๐ Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked
args: { onClick: fn() },
} satisfies Meta<typeof Button>;
export default meta;
import { fn } from 'storybook/test';
import preview from '../.storybook/preview';
import { Button } from './Button';
const meta = preview.meta({
component: Button,
// ๐ Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked
args: { onClick: fn() },
});
import { fn } from 'storybook/test';
import preview from '../.storybook/preview';
import { Button } from './Button';
const meta = preview.meta({
component: Button,
// ๐ Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked
args: { onClick: fn() },
});
import { fn } from 'storybook/test';
import preview from '../.storybook/preview';
import Button from './Button.vue';
const meta = preview.meta({
component: Button,
// ๐ Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked
args: { onClick: fn() },
});
import { fn } from 'storybook/test';
import preview from '../.storybook/preview';
import Button from './Button.vue';
const meta = preview.meta({
component: Button,
// ๐ Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked
args: { onClick: fn() },
});
import { fn } from 'storybook/test';
export default {
component: 'demo-button',
// ๐ Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked
args: { onClick: fn() },
};
import type { Meta } from '@storybook/web-components-vite';
import { fn } from 'storybook/test';
const meta: Meta = {
component: 'demo-button',
// ๐ Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked
args: { onClick: fn() },
};
export default meta;
import { fn } from 'storybook/test';
import preview from '../.storybook/preview';
const meta = preview.meta({
component: 'demo-button',
// ๐ Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked
args: { onClick: fn() },
});
import { fn } from 'storybook/test';
import preview from '../.storybook/preview';
const meta = preview.meta({
component: 'demo-button',
// ๐ Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked
args: { onClick: fn() },
});