Socket
Socket
Sign inDemoInstall

storybook-addon-vue-slots

Package Overview
Dependencies
265
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    storybook-addon-vue-slots

Vue Slots support for Storybook


Version published
Weekly downloads
10K
decreased by-6.89%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Vue

Vue Slots Addon

version version

Stand With Ukraine

Enables to use Vue slots inside Storybook's CSF files.

Features

  • Vue 3 support
  • Generate code snippets for stories with slots
  • Control specific aspect of the slot via Storybook's controls
  • Wrap slot content with components

📦 Installation

pnpm add -D storybook-addon-vue-slots

Add the storybook-addon-vue-slots to your plugins in main.ts file:

// .storybook/main.ts
export default {
  // ...
  addons: [
    // ...
    'storybook-addon-vue-slots',
  ],
} satisfies StorybookConfig

Examples

Run:

npm run storybook

To run an example Storybook

Usage

Zero

By default, the addon will pass the [slotName] arg to the template, e.x. {{ args.default }}.

Basic

Add a description to the slot by passing a string to the slot definition:

// MyComponent.stories.ts

export default meta = {
  parameters: {
    slots: {
      default: `Default slot content`,
    },
  },
}

Standard

Use args.[slotName] inside the template to pass data from Storybook controls to the slot, or access other args.

// MyComponent.stories.ts

export default meta = {
  parameters: {
    slots: {
      default: {
        description: 'Default slot',
        template: `<p>{{ args.default }}</p>`,
      },
      header: {
        description: 'Header slot',
        template: `<p>{{ args.header }}</p>`,
      },
    },
  },
}

So, value of header arg control in Storybook table is being passed into the slot template, allowing control of an aspect of the slot.

Advanced

Adding components
// MyComponent.stories.ts

export default meta = {
  parameters: {
    slots: {
      default: {
        description: 'Default slot',
        template: `<p>{{ args.default }}</p>`,
      },
      header: {
        description: 'Header slot',
        components: { AppButton },
        template: `<AppButton>{{ args.header }}</AppButton>`,
      },
    },
  },
}

Todo

  • Slots fallback support

Contribute

💖 Funding

Help support my open-source work through PayPal and GitHub Sponsors.

Donate with PayPal button

License

MIT License © 2023 Jacob Janisz

Keywords

FAQs

Last updated on 05 Jan 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc