|
| 1 | +## Custom elevation shadow color |
| 2 | +In case you also want to add a color to your shadows, you can include the following mixin directly before you execute `@include initMaterialCssVars();`. Thanks goes to @picc09 for finding this out. |
| 3 | + |
| 4 | +```scss |
| 5 | +$mat-css-palette-foreground: map-merge( |
| 6 | + // if you don't want to enter ALL the properties |
| 7 | + $mat-css-palette-foreground, |
| 8 | + ( |
| 9 | + elevation: var(--your-elevation-color-variable) |
| 10 | + // ... |
| 11 | + ) |
| 12 | +); |
| 13 | +
|
| 14 | +@mixin mat-elevation($zValue, $color: $mat-elevation-color, $opacity: $mat-elevation-opacity) { |
| 15 | + @if type-of($zValue) != number or not unitless($zValue) { |
| 16 | + @error '$zValue must be a unitless number'; |
| 17 | + } |
| 18 | + @if $zValue < 0 or $zValue > 24 { |
| 19 | + @error '$zValue must be between 0 and 24'; |
| 20 | + } |
| 21 | +
|
| 22 | + $color-umbra: $color; |
| 23 | + $color-penumbra: $color; |
| 24 | + $color-ambient: $color; |
| 25 | + @if type-of($color) != color { |
| 26 | + $color-umbra: rgba($color, $opacity * 0.2); |
| 27 | + $color-penumbra: rgba($color, $opacity * 0.14); |
| 28 | + $color-ambient: rgba($color, $opacity * 0.12); |
| 29 | + } |
| 30 | +
|
| 31 | + box-shadow: #{map-get(_get-umbra-map($color-umbra, $opacity), $zValue)}, |
| 32 | + #{map-get(_get-penumbra-map($color-penumbra, $opacity), $zValue)}, |
| 33 | + #{map-get(_get-ambient-map($color-ambient, $opacity), $zValue)}; |
| 34 | +} |
| 35 | +
|
| 36 | +// finally initialize |
| 37 | +@include initMaterialCssVars(); |
| 38 | +``` |
| 39 | +
|
| 40 | +In this way you can change `elevation: black` into variables file. |
0 commit comments