Back to Storybook

Button Story With Emojis

docs/_snippets/button-story-with-emojis.md

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

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

const meta: Meta<Button> = {
  component: Button,
};

export default meta;
type Story = StoryObj<Button>;

/*
 *๐Ÿ‘‡ Render functions are a framework specific feature to allow you control on how the component renders.
 * See https://storybook.js.org/docs/api/csf
 * to learn how to use render functions.
 */
export const Primary: Story = {
  render: () => ({
    props: {
      label: 'Button',
      backgroundColor: '#ff0',
    },
  }),
};

export const Secondary: Story = {
  render: () => ({
    props: {
      label: '๐Ÿ˜„๐Ÿ‘๐Ÿ˜๐Ÿ’ฏ',
      backgroundColor: '#ff0',
    },
  }),
};

export const Tertiary: Story = {
  render: () => ({
    props: {
      label: '๐Ÿ“š๐Ÿ“•๐Ÿ“ˆ๐Ÿค“',
      backgroundColor: '#ff0',
    },
  }),
};
ts
import preview from '../.storybook/preview';

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

const meta = preview.meta({
  component: Button,
});

/*
 *๐Ÿ‘‡ Render functions are a framework specific feature to allow you control on how the component renders.
 * See https://storybook.js.org/docs/api/csf
 * to learn how to use render functions.
 */
export const Primary = meta.story({
  render: () => ({
    props: {
      label: 'Button',
      backgroundColor: '#ff0',
    },
  }),
});

export const Secondary = meta.story({
  render: () => ({
    props: {
      label: '๐Ÿ˜„๐Ÿ‘๐Ÿ˜๐Ÿ’ฏ',
      backgroundColor: '#ff0',
    },
  }),
});

export const Tertiary = meta.story({
  render: () => ({
    props: {
      label: '๐Ÿ“š๐Ÿ“•๐Ÿ“ˆ๐Ÿค“',
      backgroundColor: '#ff0',
    },
  }),
});
js
import { createButton } from './Button';

export default {
  /* ๐Ÿ‘‡ The title prop is optional.
   * See https://storybook.js.org/docs/configure/#configure-story-loading
   * to learn how to generate automatic titles
   */
  title: 'Button',
};

/*
 *๐Ÿ‘‡ Render functions are a framework specific feature to allow you control on how the component renders.
 * See https://storybook.js.org/docs/api/csf
 * to learn how to use render functions.
 */
export const Primary = {
  render: (args) => createButton({ backgroundColor: '#ff0', label: 'Button' }),
};

export const Secondary = {
  render: (args) => createButton({ backgroundColor: '#ff0', label: '๐Ÿ˜„๐Ÿ‘๐Ÿ˜๐Ÿ’ฏ' }),
};

export const Tertiary = {
  render: (args) => createButton({ backgroundColor: '#ff0', label: '๐Ÿ“š๐Ÿ“•๐Ÿ“ˆ๐Ÿค“' }),
};
ts
import type { Meta, StoryObj } from '@storybook/html';
import { createButton, ButtonArgs } from './Button';

const meta: Meta<ButtonArgs> = {
  /* ๐Ÿ‘‡ The title prop is optional.
   * See https://storybook.js.org/docs/configure/#configure-story-loading
   * to learn how to generate automatic titles
   */
  title: 'Button',
};

export default meta;
type Story = StoryObj<ButtonArgs>;

/*
 *๐Ÿ‘‡ Render functions are a framework specific feature to allow you control on how the component renders.
 * See https://storybook.js.org/docs/api/csf
 * to learn how to use render functions.
 */
export const Primary: Story = {
  render: (args) => createButton({ backgroundColor: '#ff0', label: 'Button' }),
};

export const Secondary: Story = {
  render: (args) => createButton({ backgroundColor: '#ff0', label: '๐Ÿ˜„๐Ÿ‘๐Ÿ˜๐Ÿ’ฏ' }),
};

export const Tertiary: Story = {
  render: (args) => createButton({ backgroundColor: '#ff0', label: '๐Ÿ“š๐Ÿ“•๐Ÿ“ˆ๐Ÿค“' }),
};
jsx
import { Button } from './Button';

export default {
  component: Button,
};

/*
 *๐Ÿ‘‡ Render functions are a framework specific feature to allow you control on how the component renders.
 * See https://storybook.js.org/docs/api/csf
 * to learn how to use render functions.
 */
export const Primary = {
  render: () => <Button backgroundColor="#ff0" label="Button" />,
};

export const Secondary = {
  render: () => <Button backgroundColor="#ff0" label="๐Ÿ˜„๐Ÿ‘๐Ÿ˜๐Ÿ’ฏ" />,
};

export const Tertiary = {
  render: () => <Button backgroundColor="#ff0" label="๐Ÿ“š๐Ÿ“•๐Ÿ“ˆ๐Ÿค“" />,
};
tsx
// Replace your-framework with the framework you are using, e.g. react-vite, nextjs, nextjs-vite, etc.
import type { Meta, StoryObj } from '@storybook/your-framework';

import { Button } from './Button';

const meta = {
  component: Button,
} satisfies Meta<typeof Button>;

export default meta;
type Story = StoryObj<typeof meta>;

/*
 *๐Ÿ‘‡ Render functions are a framework specific feature to allow you control on how the component renders.
 * See https://storybook.js.org/docs/api/csf
 * to learn how to use render functions.
 */
export const Primary: Story = {
  render: () => <Button backgroundColor="#ff0" label="Button" />,
};

export const Secondary: Story = {
  render: () => <Button backgroundColor="#ff0" label="๐Ÿ˜„๐Ÿ‘๐Ÿ˜๐Ÿ’ฏ" />,
};

export const Tertiary: Story = {
  render: () => <Button backgroundColor="#ff0" label="๐Ÿ“š๐Ÿ“•๐Ÿ“ˆ๐Ÿค“" />,
};
tsx
import type { Meta, StoryObj } from 'storybook-solidjs-vite';

import { Button } from './Button';

const meta = {
  component: Button,
} satisfies Meta<typeof Button>;

export default meta;
type Story = StoryObj<typeof meta>;

/*
 *๐Ÿ‘‡ Render functions are a framework specific feature to allow you control on how the component renders.
 * See https://storybook.js.org/docs/api/csf
 * to learn how to use render functions.
 */
export const Primary: Story = {
  render: () => <Button backgroundColor="#ff0" label="Button" />,
};

export const Secondary: Story = {
  render: () => <Button backgroundColor="#ff0" label="๐Ÿ˜„๐Ÿ‘๐Ÿ˜๐Ÿ’ฏ" />,
};

export const Tertiary: Story = {
  render: () => <Button backgroundColor="#ff0" label="๐Ÿ“š๐Ÿ“•๐Ÿ“ˆ๐Ÿค“" />,
};
svelte
<script module>
  import { defineMeta } from '@storybook/addon-svelte-csf';

  import Button from './Button.svelte';

	const { Story } = defineMeta({
		component: Button,
	});
</script>

<Story name="Primary">
  <Button backgroundColor="#ff0" label="Button" />
</Story>

<Story name="Secondary">
  <Button backgroundColor="#ff0" label="๐Ÿ˜„๐Ÿ‘๐Ÿ˜๐Ÿ’ฏ" />
</Story>

<Story name="Tertiary">
  <Button backgroundColor="#ff0" label="๐Ÿ“š๐Ÿ“•๐Ÿ“ˆ๐Ÿค“" />
</Story>
js
import Button from './Button.svelte';

export default {
  component: Button,
};

/*
 *๐Ÿ‘‡ Render functions are a framework specific feature to allow you control on how the component renders.
 * See https://storybook.js.org/docs/api/csf
 * to learn how to use render functions.
 */
export const Primary = {
  render: () => ({
    Component: Button,
    props: {
      backgroundColor: '#ff0',
      label: 'Button',
    },
  }),
};

export const Secondary = {
  render: () => ({
    Component: Button,
    props: {
      backgroundColor: '#ff0',
      label: '๐Ÿ˜„๐Ÿ‘๐Ÿ˜๐Ÿ’ฏ',
    },
  }),
};

export const Tertiary = {
  render: () => ({
    Component: Button,
    props: {
      backgroundColor: '#ff0',
      label: '๐Ÿ“š๐Ÿ“•๐Ÿ“ˆ๐Ÿค“',
    },
  }),
};
svelte
<script module>
  import { defineMeta } from '@storybook/addon-svelte-csf';

  import Button from './Button.svelte';

	const { Story } = defineMeta({
		component: Button,
	});
</script>

<Story name="Primary">
  <Button backgroundColor="#ff0" label="Button" />
</Story>

<Story name="Secondary">
  <Button backgroundColor="#ff0" label="๐Ÿ˜„๐Ÿ‘๐Ÿ˜๐Ÿ’ฏ" />
</Story>

<Story name="Tertiary">
  <Button backgroundColor="#ff0" label="๐Ÿ“š๐Ÿ“•๐Ÿ“ˆ๐Ÿค“" />
</Story>
ts
// Replace your-framework with svelte-vite or sveltekit
import type { Meta, StoryObj } from '@storybook/your-framework';

import Button from './Button.svelte';

const meta = {
  component: Button,
} satisfies Meta<typeof Button>;

export default meta;
type Story = StoryObj<typeof meta>;

/*
 *๐Ÿ‘‡ Render functions are a framework specific feature to allow you control on how the component renders.
 * See https://storybook.js.org/docs/svelte/api/csf
 * to learn how to use render functions.
 */
export const Primary: Story = {
  render: () => ({
    Component: Button,
    props: {
      backgroundColor: '#ff0',
      label: 'Button',
    },
  }),
};

export const Secondary: Story = {
  render: () => ({
    Component: Button,
    props: {
      backgroundColor: '#ff0',
      label: '๐Ÿ˜„๐Ÿ‘๐Ÿ˜๐Ÿ’ฏ',
    },
  }),
};

export const Tertiary: Story = {
  render: () => ({
    Component: Button,
    props: {
      backgroundColor: '#ff0',
      label: '๐Ÿ“š๐Ÿ“•๐Ÿ“ˆ๐Ÿค“',
    },
  }),
};
js
import Button from './Button.vue';

export default {
  component: Button,
};

/*
 *๐Ÿ‘‡ Render functions are a framework specific feature to allow you control on how the component renders.
 * See https://storybook.js.org/docs/api/csf
 * to learn how to use render functions.
 */
export const Primary = {
  render: () => ({
    components: { Button },
    template: '<Button backgroundColor="#ff0" label="Button" />',
  }),
};

export const Secondary = {
  render: () => ({
    components: { Button },
    template: '<Button backgroundColor="#ff0" label="๐Ÿ˜„๐Ÿ‘๐Ÿ˜๐Ÿ’ฏ" />',
  }),
};

export const Tertiary = {
  render: () => ({
    components: { Button },
    template: '<Button backgroundColor="#ff0" label="๐Ÿ“š๐Ÿ“•๐Ÿ“ˆ๐Ÿค“" />',
  }),
};
ts
import type { Meta, StoryObj } from '@storybook/vue3-vite';

import Button from './Button.vue';

const meta = {
  component: Button,
} satisfies Meta<typeof Button>;

export default meta;
type Story = StoryObj<typeof Button>;

/*
 *๐Ÿ‘‡ Render functions are a framework specific feature to allow you control on how the component renders.
 * See https://storybook.js.org/docs/api/csf
 * to learn how to use render functions.
 */
export const Primary: Story = {
  render: () => ({
    components: { Button },
    template: '<Button backgroundColor="#ff0" label="Button" />',
  }),
};

export const Secondary: Story = {
  render: () => ({
    components: { Button },
    template: '<Button backgroundColor="#ff0" label="๐Ÿ˜„๐Ÿ‘๐Ÿ˜๐Ÿ’ฏ" />',
  }),
};

export const Tertiary: Story = {
  render: () => ({
    components: { Button },
    template: '<Button backgroundColor="#ff0" label="๐Ÿ“š๐Ÿ“•๐Ÿ“ˆ๐Ÿค“" />',
  }),
};
js
import { html } from 'lit';

export default {
  component: 'demo-button',
};

/*
 *๐Ÿ‘‡ Render functions are a framework specific feature to allow you control on how the component renders.
 * See https://storybook.js.org/docs/api/csf
 * to learn how to use render functions.
 */
export const Primary = {
  render: () => html`<demo-button .backgroundColor="#ff0" .label="Button"></demo-button>`,
};

export const Secondary = {
  render: () => html`<demo-button .backgroundColor="#ff0" .label="๐Ÿ˜„๐Ÿ‘๐Ÿ˜๐Ÿ’ฏ"></demo-button>`,
};

export const Tertiary = {
  render: () => html`<demo-button .backgroundColor="#ff0" .label="๐Ÿ“š๐Ÿ“•๐Ÿ“ˆ๐Ÿค“"></demo-button>`,
};
ts
import type { Meta, StoryObj } from '@storybook/web-components-vite';

import { html } from 'lit';

const meta: Meta = {
  component: 'demo-button',
};

export default meta;
type Story = StoryObj;

/*
 *๐Ÿ‘‡ Render functions are a framework specific feature to allow you control on how the component renders.
 * See https://storybook.js.org/docs/api/csf
 * to learn how to use render functions.
 */
export const Primary: Story = {
  render: () => html`<demo-button .backgroundColor="#ff0" .label="Button"></demo-button>`,
};

export const Secondary: Story = {
  render: () => html`<demo-button .backgroundColor="#ff0" .label="๐Ÿ˜„๐Ÿ‘๐Ÿ˜๐Ÿ’ฏ"></demo-button>`,
};

export const Tertiary: Story = {
  render: () => html`<demo-button .backgroundColor="#ff0" .label="๐Ÿ“š๐Ÿ“•๐Ÿ“ˆ๐Ÿค“"></demo-button>`,
};
js
import { html } from 'lit';

import preview from '../.storybook/preview';

const meta = preview.meta({
  component: 'demo-button',
});

/*
 *๐Ÿ‘‡ Render functions are a framework specific feature to allow you control on how the component renders.
 * See https://storybook.js.org/docs/api/csf
 * to learn how to use render functions.
 */
export const Primary = meta.story({
  render: () => html`<demo-button .backgroundColor="#ff0" .label="Button"></demo-button>`,
});

export const Secondary = meta.story({
  render: () => html`<demo-button .backgroundColor="#ff0" .label="๐Ÿ˜„๐Ÿ‘๐Ÿ˜๐Ÿ’ฏ"></demo-button>`,
});

export const Tertiary = meta.story({
  render: () => html`<demo-button .backgroundColor="#ff0" .label="๐Ÿ“š๐Ÿ“•๐Ÿ“ˆ๐Ÿค“"></demo-button>`,
});
ts
import { html } from 'lit';

import preview from '../.storybook/preview';

const meta = preview.meta({
  component: 'demo-button',
});

/*
 *๐Ÿ‘‡ Render functions are a framework specific feature to allow you control on how the component renders.
 * See https://storybook.js.org/docs/api/csf
 * to learn how to use render functions.
 */
export const Primary = meta.story({
  render: () => html`<demo-button .backgroundColor="#ff0" .label="Button"></demo-button>`,
});

export const Secondary = meta.story({
  render: () => html`<demo-button .backgroundColor="#ff0" .label="๐Ÿ˜„๐Ÿ‘๐Ÿ˜๐Ÿ’ฏ"></demo-button>`,
});

export const Tertiary = meta.story({
  render: () => html`<demo-button .backgroundColor="#ff0" .label="๐Ÿ“š๐Ÿ“•๐Ÿ“ˆ๐Ÿค“"></demo-button>`,
});
ts
import preview from '../.storybook/preview';

import Button from './Button.vue';

const meta = preview.meta({
  component: Button,
});

/*
 *๐Ÿ‘‡ Render functions are a framework specific feature to allow you control on how the component renders.
 * See https://storybook.js.org/docs/api/csf
 * to learn how to use render functions.
 */
export const Primary = meta.story({
  render: () => ({
    components: { Button },
    template: '<Button backgroundColor="#ff0" label="Button" />',
  }),
});

export const Secondary = meta.story({
  render: () => ({
    components: { Button },
    template: '<Button backgroundColor="#ff0" label="๐Ÿ˜„๐Ÿ‘๐Ÿ˜๐Ÿ’ฏ" />',
  }),
});

export const Tertiary = meta.story({
  render: () => ({
    components: { Button },
    template: '<Button backgroundColor="#ff0" label="๐Ÿ“š๐Ÿ“•๐Ÿ“ˆ๐Ÿค“" />',
  }),
});
<!-- 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,
});

/*
 *๐Ÿ‘‡ Render functions are a framework specific feature to allow you control on how the component renders.
 * See https://storybook.js.org/docs/api/csf
 * to learn how to use render functions.
 */
export const Primary = meta.story({
  render: () => ({
    components: { Button },
    template: '<Button backgroundColor="#ff0" label="Button" />',
  }),
});

export const Secondary = meta.story({
  render: () => ({
    components: { Button },
    template: '<Button backgroundColor="#ff0" label="๐Ÿ˜„๐Ÿ‘๐Ÿ˜๐Ÿ’ฏ" />',
  }),
});

export const Tertiary = meta.story({
  render: () => ({
    components: { Button },
    template: '<Button backgroundColor="#ff0" label="๐Ÿ“š๐Ÿ“•๐Ÿ“ˆ๐Ÿค“" />',
  }),
});
tsx
import preview from '../.storybook/preview';

import { Button } from './Button';

const meta = preview.meta({
  component: Button,
});

/*
 *๐Ÿ‘‡ Render functions are a framework specific feature to allow you control on how the component renders.
 * See https://storybook.js.org/docs/api/csf
 * to learn how to use render functions.
 */
export const Primary = meta.story({
  render: () => <Button backgroundColor="#ff0" label="Button" />,
});

export const Secondary = meta.story({
  render: () => <Button backgroundColor="#ff0" label="๐Ÿ˜„๐Ÿ‘๐Ÿ˜๐Ÿ’ฏ" />,
});

export const Tertiary = meta.story({
  render: () => <Button backgroundColor="#ff0" label="๐Ÿ“š๐Ÿ“•๐Ÿ“ˆ๐Ÿค“" />,
});
<!-- JS snippets still needed while providing both CSF 3 & Next -->
jsx
import preview from '../.storybook/preview';

import { Button } from './Button';

const meta = preview.meta({
  component: Button,
});

/*
 *๐Ÿ‘‡ Render functions are a framework specific feature to allow you control on how the component renders.
 * See https://storybook.js.org/docs/api/csf
 * to learn how to use render functions.
 */
export const Primary = meta.story({
  render: () => <Button backgroundColor="#ff0" label="Button" />,
});

export const Secondary = meta.story({
  render: () => <Button backgroundColor="#ff0" label="๐Ÿ˜„๐Ÿ‘๐Ÿ˜๐Ÿ’ฏ" />,
});

export const Tertiary = meta.story({
  render: () => <Button backgroundColor="#ff0" label="๐Ÿ“š๐Ÿ“•๐Ÿ“ˆ๐Ÿค“" />,
});