Angular Material - Angular Material Theme - Angular Material Tutorial
How to Create Theme in Angular Material?
- A theme is a composition of color palettes. That’s right, not just a single color palette, multiple color palettes.
- This is a very powerful setup to define themes in a very flexible way.
learn angular material tutorials - themes Example
- As for Angular Material, it boils down to five different color palettes with each being used for different parts of the design:
- Primary - Main colors most widely used across all screens and components.
- Accent - Also known as the secondary color. Used for floating action buttons and interactive elements.
- Warn - Colors to convey error state.
- Foreground - Used for text and icons.
- Background - Colors used for element backgrounds.
Related Tags - angular material , angular 2 material , angular material 2 , angular material design , material angular
Using a pre-built theme:
- Angular Material comes prepackaged with several pre-built theme css files. These theme files also include all of the styles for core (styles common to all components), so you only have to include a single css file for Angular Material in your app.
- You can include a theme file directly into your application from @angular/material/prebuilt-themes
Available pre-built themes:
- deeppurple-amber.css
- indigo-pink.css
- pink-bluegrey.css
- purple-green.css
- If you're using Angular CLI, this is as simple as including one line in your styles.css file:
- Alternatively, you can just reference the file directly. This would look something like:
- The actual path will depend on your server setup.
- You can also concatenate the file with the rest of your application's css.
- Finally, if your app's content is not placed inside of a md-sidenav-container element, you need to add the mat-app-background class to your wrapper element (for example the body).
- This ensures that the proper theme background is applied to your page.
- Angular Material Components uses intention group classes like md-primary, md-accent, md-warn and additional classes for color differences like md-hue-1, md-hue-2, or md-hue-3.
Following components supports use of above mentioned classes:
- md-button
- md-checkbox
- md-progress-circular
- md-progress-linear
- md-radio-button
- md-slider
- md-switch
- md-tabs
- md-text-float
- md-toolbar
Using a pre-built theme: Example:
- The following example showcases the use of themes in Angular JS application.