This recipe assumes that you already have an Angular app using @angular/material
and have just set up Storybook >= 7.0 using the getting started guide. Don't have this? Follow the Angular material setup instructions then run:
@angular/material
depends on two fonts to render as intended, Google’s Roboto
and Material Icons
. While you can load these fonts directly from the Google Fonts CDN, bundling fonts with Storybook is better for performance.
To get started, install the fonts as dependencies.
Then include the fonts in your angular.json
file.
Now that you have Storybook set up, you can start writing stories for your components. Let's start with a NavBarComponent
. For Standalone components, any Material components that you import through the @Component
decorator will be available to your component in Storybook.
This means that you can just supply the NavBarComponent
to the component
property of the Meta
object in your stories file.
For Module components, you will need to import the Material components that you want to use in your stories file. You can supply them to Storybook using the moduleMetadata
decorator in the Meta
object of the stories file.