storybookjs / addon-svelte-csf

[Incubation] CSF using Svelte components.
MIT License
98 stars 29 forks source link

How to provide slots in stories? #104

Closed galenwinsor closed 1 year ago

galenwinsor commented 1 year ago

If I have a component with one or more slots, how do I declare them in the <Template> component?

JReinhold commented 1 year ago

I don't think you can spread slots natively in Svelte similar to how you can spread props, this is just how Svelte works. You need to define the slot content as you'd regular do with Svelte, either in the Template or in each story if you need to override it.

You can see an example here where the slot content for the button is both defined in the Template, and overwritten in a specific story.

https://github.com/storybookjs/addon-svelte-csf/blob/main/stories/button.stories.svelte

galenwinsor commented 1 year ago

Great, thanks!