Skip to content

Commit 4bf4b87

Browse files
crisbetommalerba
authored andcommitted
feat(theming): provide a content wrapper attribute (#2170)
Adds the `md-app-background` class which users can apply to their wrapper element, in order to provide the theme background. This is necessary, because the only element that does this at the moment is `md-sidenav-container` and it's not something that necessarily everybody uses. Fixes #1938. Fixes #2106.
1 parent f11c5eb commit 4bf4b87

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

guides/theming.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ The actual path will depend on your server setup.
4040

4141
You can also concatenate the file with the rest of your application's css.
4242

43+
Finally, if your app's content **is not** placed inside of a `md-sidenav-container` element, you
44+
need to add the `md-app-background` class to your wrapper element (for example the `body`). This
45+
ensures that the proper theme background is applied to your page.
46+
4347
### Defining a custom theme
4448
When you want more customization than a pre-built theme offers, you can create your own theme file.
4549

@@ -98,7 +102,7 @@ secondary dark theme:
98102

99103
$dark-theme: md-dark-theme($dark-primary, $dark-accent, $dark-warn);
100104

101-
@include angular-material-theme($dark-theme);
105+
@include angular-material-theme($dark-theme);
102106
}
103107
```
104108

src/lib/core/_core.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,11 @@
2727
@mixin md-core-theme($theme) {
2828
@include md-ripple-theme($theme);
2929
@include md-option-theme($theme);
30+
31+
// Wrapper element that provides the theme background when the
32+
// user's content isn't inside of a `md-sidenav-container`.
33+
.md-app-background {
34+
$background: map-get($theme, background);
35+
background-color: md-color($background, background);
36+
}
3037
}

0 commit comments

Comments
 (0)