Active
Project:
Storybook
Version:
1.0.0
Component:
Twig
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
30 Oct 2024 at 09:04 UTC
Updated:
11 Nov 2025 at 17:15 UTC
Jump to comment: Most recent
When creating stories, if you have multiplies stories in one *.stories.twig file like the following, then instead of each story having one template included, each story ends up getting multiple embeds.
In other words, I expect to see one button per story, but instead I see two next to each other in Storybook.
{% stories chip with {title: 'Dreamykit/Simple components/Button',} %}
{% story default with {
name: '1. Button',
args: {
type: 'button',
input_type: '',
text: 'button',
href: '',
target: '',
}
} %}
{{ include('dreamykit:button') }}
{% endstory %}
{% story default with {
name: '2. Link button',
args: {
type: 'link',
input_type: '',
text: 'link',
href: '#',
target: '_blank',
}
} %}
{{ include('dreamykit:button') }}
{% endstory %}
{% endstories %}Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
droces commentedAs a workaround, I have found that I can embed the component just once (inside one of the stories) like the following, and it will show once for each story (in other words, I see only one button in each story). However this won't work if my includes / embeds are not the same for each story, so it won't work in many cases.
Comment #3
13twelve commentedAny update or advice here?
Being able to write multiple stories for a component is a useful feature.
Comment #4
13twelve commentedInitially I was getting around this by adding multiple `*.stories.twig` files, it seems as long as you match the `title`'s between your stories then it seems to compile and group in Storybook.
And then I tried altering the ID of the story...
```
{% story default with {
name: '1. Default',
} %}
...
{% endstory %}
{% story alt with {
name: '2. Alt',
} %}
...
{% endstory %}
```
This then allows multiple stories inside a single stories file.
So, I think this issue is actually not an issue, its just not clear how to have multiple stories (very possibly user error 🤷🏻♂️).
At any rate, might be worth adding to the readme to make it clearer - I'll make a MR:
https://git.drupalcode.org/project/storybook/-/merge_requests/26
cc. @droces