Skip to content

Applying Global Stylesheets per Story in a Shared Angular Storybook #29141

Answered by Marklb
lundmikkel asked this question in Help
Discussion options

You must be logged in to vote

There is probably a better way to do this, but I think your idea of a wrapper component was a straightforward solution that sticks to what Angular already provides. It is a bit of boilerplate for just styles, though. If you just change the component's encapsulation, the styles wont get scoped.

I have been busy this week, but when I get time I will see if I can find any example projects I have made for people solving similar problems.

Here is a quickly thrown together snippet of what I mean:

@Component({
  selector: 'story-styles-1',
  standalone: true,
  template: `<ng-content></ng-content>`,
  styles: [`
    body {
      background-color: rgba(30,30,30,1);
    }
  `],
  encapsulation: Vi…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by lundmikkel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants