UNPKG

227 kBSCSSView Raw
1// File for which all imports are resolved and bundled. This is the entry-point for
2// the `@angular/material` theming Sass bundle. See `//src/material:theming_bundle`.
3
4// Import all the theming functionality.
5// We want overlays to always appear over user content, so set a baseline
6// very high z-index for the overlay container, which is where we create the new
7// stacking context for all overlays.
8$cdk-z-index-overlay-container: 1000 !default;
9$cdk-z-index-overlay: 1000 !default;
10$cdk-z-index-overlay-backdrop: 1000 !default;
11
12// Background color for all of the backdrops
13$cdk-overlay-dark-backdrop-background: rgba(0, 0, 0, 0.32) !default;
14
15// Default backdrop animation is based on the Material Design swift-ease-out.
16$backdrop-animation-duration: 400ms !default;
17$backdrop-animation-timing-function: cubic-bezier(0.25, 0.8, 0.25, 1) !default;
18
19
20@mixin cdk-overlay() {
21 .cdk-overlay-container, .cdk-global-overlay-wrapper {
22 // Disable events from being captured on the overlay container.
23 pointer-events: none;
24
25 // The container should be the size of the viewport.
26 top: 0;
27 left: 0;
28 height: 100%;
29 width: 100%;
30 }
31
32 // The overlay-container is an invisible element which contains all individual overlays.
33 .cdk-overlay-container {
34 position: fixed;
35 z-index: $cdk-z-index-overlay-container;
36
37 &:empty {
38 // Hide the element when it doesn't have any child nodes. This doesn't
39 // include overlays that have been detached, rather than disposed.
40 display: none;
41 }
42 }
43
44 // We use an extra wrapper element in order to use make the overlay itself a flex item.
45 // This makes centering the overlay easy without running into the subpixel rendering
46 // problems tied to using `transform` and without interfering with the other position
47 // strategies.
48 .cdk-global-overlay-wrapper {
49 display: flex;
50 position: absolute;
51 z-index: $cdk-z-index-overlay;
52 }
53
54 // A single overlay pane.
55 .cdk-overlay-pane {
56 // Note: it's important for this one to start off `absolute`,
57 // in order for us to be able to measure it correctly.
58 position: absolute;
59 pointer-events: auto;
60 box-sizing: border-box;
61 z-index: $cdk-z-index-overlay;
62
63 // For connected-position overlays, we set `display: flex` in
64 // order to force `max-width` and `max-height` to take effect.
65 display: flex;
66 max-width: 100%;
67 max-height: 100%;
68 }
69
70 .cdk-overlay-backdrop {
71 // TODO(jelbourn): reuse sidenav fullscreen mixin.
72 position: absolute;
73 top: 0;
74 bottom: 0;
75 left: 0;
76 right: 0;
77
78 z-index: $cdk-z-index-overlay-backdrop;
79 pointer-events: auto;
80 -webkit-tap-highlight-color: transparent;
81 transition: opacity $backdrop-animation-duration $backdrop-animation-timing-function;
82 opacity: 0;
83
84 &.cdk-overlay-backdrop-showing {
85 opacity: 1;
86
87 // Note that we can't import and use the `high-contrast` mixin from `_a11y.scss`, because
88 // this file will be copied to the top-level `cdk` package when putting together the files
89 // for npm. Any relative import paths we use here will become invalid once the file is copied.
90 .cdk-high-contrast-active & {
91 // In high contrast mode the rgba background will become solid
92 // so we need to fall back to making it opaque using `opacity`.
93 opacity: 0.6;
94 }
95 }
96 }
97
98 .cdk-overlay-dark-backdrop {
99 background: $cdk-overlay-dark-backdrop-background;
100 }
101
102 .cdk-overlay-transparent-backdrop {
103 // Note: as of Firefox 57, having the backdrop be `background: none` will prevent it from
104 // capturing the user's mouse scroll events. Since we also can't use something like
105 // `rgba(0, 0, 0, 0)`, we work around the inconsistency by not setting the background at
106 // all and using `opacity` to make the element transparent.
107 &, &.cdk-overlay-backdrop-showing {
108 opacity: 0;
109 }
110 }
111
112 // Overlay parent element used with the connected position strategy. Used to constrain the
113 // overlay element's size to fit within the viewport.
114 .cdk-overlay-connected-position-bounding-box {
115 position: absolute;
116 z-index: $cdk-z-index-overlay;
117
118 // We use `display: flex` on this element exclusively for centering connected overlays.
119 // When *not* centering, a top/left/bottom/right will be set which overrides the normal
120 // flex layout.
121 display: flex;
122
123 // We use the `column` direction here to avoid some flexbox issues in Edge
124 // when using the "grow after open" options.
125 flex-direction: column;
126
127 // Add some dimensions so the element has an `innerText` which some people depend on in tests.
128 min-width: 1px;
129 min-height: 1px;
130 }
131
132 // Used when disabling global scrolling.
133 .cdk-global-scrollblock {
134 position: fixed;
135
136 // Necessary for the content not to lose its width. Note that we're using 100%, instead of
137 // 100vw, because 100vw includes the width plus the scrollbar, whereas 100% is the width
138 // that the element had before we made it `fixed`.
139 width: 100%;
140
141 // Note: this will always add a scrollbar to whatever element it is on, which can
142 // potentially result in double scrollbars. It shouldn't be an issue, because we won't
143 // block scrolling on a page that doesn't have a scrollbar in the first place.
144 overflow-y: scroll;
145 }
146}
147
148@mixin cdk-a11y {
149 .cdk-visually-hidden {
150 border: 0;
151 clip: rect(0 0 0 0);
152 height: 1px;
153 margin: -1px;
154 overflow: hidden;
155 padding: 0;
156 position: absolute;
157 width: 1px;
158
159 // Avoid browsers rendering the focus ring in some cases.
160 outline: 0;
161
162 // Avoid some cases where the browser will still render the native controls (see #9049).
163 -webkit-appearance: none;
164 -moz-appearance: none;
165 }
166}
167
168/// Emits the mixin's content nested under `$selector-context` if `$selector-context`
169/// is non-empty.
170/// @param selector-context The selector under which to nest the mixin's content.
171@mixin _cdk-optionally-nest-content($selector-context) {
172 @if ($selector-context == '') {
173 @content;
174 }
175 @else {
176 #{$selector-context} {
177 @content;
178 }
179 }
180}
181
182/// Applies styles for users in high contrast mode. Note that this only applies
183/// to Microsoft browsers. Chrome can be included by checking for the `html[hc]`
184/// attribute, however Chrome handles high contrast differently.
185///
186/// @param target Which kind of high contrast setting to target. Defaults to `active`, can be
187/// `white-on-black` or `black-on-white`.
188/// @param encapsulation Whether to emit styles for view encapsulation. Values are:
189/// * `on` - works for `Emulated`, `Native`, and `ShadowDom`
190/// * `off` - works for `None`
191/// * `any` - works for all encapsulation modes by emitting the CSS twice (default).
192@mixin cdk-high-contrast($target: active, $encapsulation: 'any') {
193 @if ($target != 'active' and $target != 'black-on-white' and $target != 'white-on-black') {
194 @error 'Unknown cdk-high-contrast value "#{$target}" provided. ' +
195 'Allowed values are "active", "black-on-white", and "white-on-black"';
196 }
197
198 @if ($encapsulation != 'on' and $encapsulation != 'off' and $encapsulation != 'any') {
199 @error 'Unknown cdk-high-contrast encapsulation "#{$encapsulation}" provided. ' +
200 'Allowed values are "on", "off", and "any"';
201 }
202
203 // If the selector context has multiple parts, such as `.section, .region`, just doing
204 // `.cdk-high-contrast-xxx #{&}` will only apply the parent selector to the first part of the
205 // context. We address this by nesting the selector context under .cdk-high-contrast.
206 @at-root {
207 $selector-context: #{&};
208
209 @if ($encapsulation != 'on') {
210 // Note that if this selector is updated, the same change has to be made inside
211 // `_overlay.scss` which can't depend on this mixin due to some infrastructure limitations.
212 .cdk-high-contrast-#{$target} {
213 @include _cdk-optionally-nest-content($selector-context) {
214 @content;
215 }
216 }
217 }
218
219 @if ($encapsulation != 'off') {
220 .cdk-high-contrast-#{$target} :host {
221 @include _cdk-optionally-nest-content($selector-context) {
222 @content;
223 }
224 }
225 }
226 }
227}
228
229// Core styles that enable monitoring autofill state of text fields.
230@mixin cdk-text-field {
231 // Keyframes that apply no styles, but allow us to monitor when an text field becomes autofilled
232 // by watching for the animation events that are fired when they start. Note: the /*!*/ comment is
233 // needed to prevent LibSass from stripping the keyframes out.
234 // Based on: https://medium.com/@brunn/detecting-autofilled-fields-in-javascript-aed598d25da7
235 @keyframes cdk-text-field-autofill-start {/*!*/}
236 @keyframes cdk-text-field-autofill-end {/*!*/}
237
238 .cdk-text-field-autofill-monitored:-webkit-autofill {
239 // Since Chrome 80 we need a 1ms delay, or the animationstart event won't fire.
240 animation: cdk-text-field-autofill-start 0s 1ms;
241 }
242
243 .cdk-text-field-autofill-monitored:not(:-webkit-autofill) {
244 // Since Chrome 80 we need a 1ms delay, or the animationstart event won't fire.
245 animation: cdk-text-field-autofill-end 0s 1ms;
246 }
247
248 // Remove the resize handle on autosizing textareas, because whatever height
249 // the user resized to will be overwritten once they start typing again.
250 textarea.cdk-textarea-autosize {
251 resize: none;
252 }
253
254 // This class is temporarily applied to the textarea when it is being measured. It is immediately
255 // removed when measuring is complete. We use `!important` rules here to make sure user-specified
256 // rules do not interfere with the measurement.
257 textarea.cdk-textarea-autosize-measuring {
258 @include _cdk-textarea-autosize-measuring-base;
259 height: auto !important;
260 overflow: hidden !important;
261 }
262
263 // Similar to the `cdk-textarea-autosize-measuring` class, but only applied on Firefox. We need
264 // to use this class, because Firefox has a bug where changing the `overflow` breaks the user's
265 // ability to undo/redo what they were typing (see #16629). This class is only scoped to Firefox,
266 // because the measurements there don't seem to be affected by the `height: 0`, whereas on other
267 // browsers they are, e.g. Chrome detects longer text and IE does't resize back to normal.
268 // Identical issue report: https://bugzilla.mozilla.org/show_bug.cgi?id=448784
269 textarea.cdk-textarea-autosize-measuring-firefox {
270 @include _cdk-textarea-autosize-measuring-base;
271 height: 0 !important;
272 }
273}
274
275@mixin _cdk-textarea-autosize-measuring-base {
276 // Having 2px top and bottom padding seems to fix a bug where Chrome gets an incorrect
277 // measurement. We just have to account for it later and subtract it off the final result.
278 padding: 2px 0 !important;
279 box-sizing: content-box !important;
280}
281
282// Used to generate UIDs for keyframes used to change the text field autofill styles.
283$cdk-text-field-autofill-color-frame-count: 0;
284
285// Mixin used to apply custom background and foreground colors to an autofilled text field.
286// Based on: https://stackoverflow.com/questions/2781549/
287// removing-input-background-colour-for-chrome-autocomplete#answer-37432260
288@mixin cdk-text-field-autofill-color($background, $foreground:'') {
289 @keyframes cdk-text-field-autofill-color-#{$cdk-text-field-autofill-color-frame-count} {
290 to {
291 background: $background;
292 @if $foreground != '' { color: $foreground; }
293 }
294 }
295
296 &:-webkit-autofill {
297 animation: cdk-text-field-autofill-color-#{$cdk-text-field-autofill-color-frame-count} both;
298 }
299
300 &.cdk-text-field-autofill-monitored:-webkit-autofill {
301 // Since Chrome 80 we need a 1ms delay for cdk-text-field-autofill-start, or the animationstart
302 // event won't fire.
303 animation: cdk-text-field-autofill-start 0s 1ms,
304 cdk-text-field-autofill-color-#{$cdk-text-field-autofill-color-frame-count} both;
305 }
306
307 $cdk-text-field-autofill-color-frame-count:
308 $cdk-text-field-autofill-color-frame-count + 1 !global;
309}
310
311
312// Core styles that can be used to apply material design treatments to any element.
313// Media queries
314// TODO(josephperrott): Change $mat-xsmall and $mat-small usages to rely on BreakpointObserver,
315$mat-xsmall: 'max-width: 599px';
316$mat-small: 'max-width: 959px';
317
318// TODO: Revisit all z-indices before beta
319// z-index master list
320
321$z-index-fab: 20 !default;
322$z-index-drawer: 100 !default;
323
324// Global constants
325$pi: 3.14159265;
326
327// Padding between input toggles and their labels
328$mat-toggle-padding: 8px !default;
329// Width and height of input toggles
330$mat-toggle-size: 20px !default;
331
332// Easing Curves
333// TODO(jelbourn): all of these need to be revisited
334
335// The default animation curves used by material design.
336$mat-linear-out-slow-in-timing-function: cubic-bezier(0, 0, 0.2, 0.1) !default;
337$mat-fast-out-slow-in-timing-function: cubic-bezier(0.4, 0, 0.2, 1) !default;
338$mat-fast-out-linear-in-timing-function: cubic-bezier(0.4, 0, 1, 1) !default;
339
340$ease-in-out-curve-function: cubic-bezier(0.35, 0, 0.25, 1) !default;
341
342$swift-ease-out-duration: 400ms !default;
343$swift-ease-out-timing-function: cubic-bezier(0.25, 0.8, 0.25, 1) !default;
344$swift-ease-out: all $swift-ease-out-duration $swift-ease-out-timing-function !default;
345
346$swift-ease-in-duration: 300ms !default;
347$swift-ease-in-timing-function: cubic-bezier(0.55, 0, 0.55, 0.2) !default;
348$swift-ease-in: all $swift-ease-in-duration $swift-ease-in-timing-function !default;
349
350$swift-ease-in-out-duration: 500ms !default;
351$swift-ease-in-out-timing-function: $ease-in-out-curve-function !default;
352$swift-ease-in-out: all $swift-ease-in-out-duration $swift-ease-in-out-timing-function !default;
353
354$swift-linear-duration: 80ms !default;
355$swift-linear-timing-function: linear !default;
356$swift-linear: all $swift-linear-duration $swift-linear-timing-function !default;
357
358
359
360// A collection of mixins and CSS classes that can be used to apply elevation to a material
361// element.
362// See: https://material.io/design/environment/elevation.html
363// Examples:
364//
365//
366// .mat-foo {
367// @include $mat-elevation(2);
368//
369// &:active {
370// @include $mat-elevation(8);
371// }
372// }
373//
374// <div id="external-card" class="mat-elevation-z2"><p>Some content</p></div>
375//
376// For an explanation of the design behind how elevation is implemented, see the design doc at
377// https://goo.gl/Kq0k9Z.
378
379// Colors for umbra, penumbra, and ambient shadows. As described in the design doc, each elevation
380// level is created using a set of 3 shadow values, one for umbra (the shadow representing the
381// space completely obscured by an object relative to its light source), one for penumbra (the
382// space partially obscured by an object), and one for ambient (the space which contains the object
383// itself). For a further explanation of these terms and their meanings, see
384// https://en.wikipedia.org/wiki/Umbra,_penumbra_and_antumbra.
385
386// Maps for the different shadow sets and their values within each z-space. These values were
387// created by taking a few reference shadow sets created by Google's Designers and interpolating
388// all of the values between them.
389
390@function _get-umbra-map($color, $opacity) {
391 $shadow-color: if(type-of($color) == color, rgba($color, $opacity * 0.2), $color);
392
393 @return (
394 0: '0px 0px 0px 0px #{$shadow-color}',
395 1: '0px 2px 1px -1px #{$shadow-color}',
396 2: '0px 3px 1px -2px #{$shadow-color}',
397 3: '0px 3px 3px -2px #{$shadow-color}',
398 4: '0px 2px 4px -1px #{$shadow-color}',
399 5: '0px 3px 5px -1px #{$shadow-color}',
400 6: '0px 3px 5px -1px #{$shadow-color}',
401 7: '0px 4px 5px -2px #{$shadow-color}',
402 8: '0px 5px 5px -3px #{$shadow-color}',
403 9: '0px 5px 6px -3px #{$shadow-color}',
404 10: '0px 6px 6px -3px #{$shadow-color}',
405 11: '0px 6px 7px -4px #{$shadow-color}',
406 12: '0px 7px 8px -4px #{$shadow-color}',
407 13: '0px 7px 8px -4px #{$shadow-color}',
408 14: '0px 7px 9px -4px #{$shadow-color}',
409 15: '0px 8px 9px -5px #{$shadow-color}',
410 16: '0px 8px 10px -5px #{$shadow-color}',
411 17: '0px 8px 11px -5px #{$shadow-color}',
412 18: '0px 9px 11px -5px #{$shadow-color}',
413 19: '0px 9px 12px -6px #{$shadow-color}',
414 20: '0px 10px 13px -6px #{$shadow-color}',
415 21: '0px 10px 13px -6px #{$shadow-color}',
416 22: '0px 10px 14px -6px #{$shadow-color}',
417 23: '0px 11px 14px -7px #{$shadow-color}',
418 24: '0px 11px 15px -7px #{$shadow-color}'
419 );
420}
421
422@function _get-penumbra-map($color, $opacity) {
423 $shadow-color: if(type-of($color) == color, rgba($color, $opacity * 0.14), $color);
424
425 @return (
426 0: '0px 0px 0px 0px #{$shadow-color}',
427 1: '0px 1px 1px 0px #{$shadow-color}',
428 2: '0px 2px 2px 0px #{$shadow-color}',
429 3: '0px 3px 4px 0px #{$shadow-color}',
430 4: '0px 4px 5px 0px #{$shadow-color}',
431 5: '0px 5px 8px 0px #{$shadow-color}',
432 6: '0px 6px 10px 0px #{$shadow-color}',
433 7: '0px 7px 10px 1px #{$shadow-color}',
434 8: '0px 8px 10px 1px #{$shadow-color}',
435 9: '0px 9px 12px 1px #{$shadow-color}',
436 10: '0px 10px 14px 1px #{$shadow-color}',
437 11: '0px 11px 15px 1px #{$shadow-color}',
438 12: '0px 12px 17px 2px #{$shadow-color}',
439 13: '0px 13px 19px 2px #{$shadow-color}',
440 14: '0px 14px 21px 2px #{$shadow-color}',
441 15: '0px 15px 22px 2px #{$shadow-color}',
442 16: '0px 16px 24px 2px #{$shadow-color}',
443 17: '0px 17px 26px 2px #{$shadow-color}',
444 18: '0px 18px 28px 2px #{$shadow-color}',
445 19: '0px 19px 29px 2px #{$shadow-color}',
446 20: '0px 20px 31px 3px #{$shadow-color}',
447 21: '0px 21px 33px 3px #{$shadow-color}',
448 22: '0px 22px 35px 3px #{$shadow-color}',
449 23: '0px 23px 36px 3px #{$shadow-color}',
450 24: '0px 24px 38px 3px #{$shadow-color}'
451 );
452}
453
454@function _get-ambient-map($color, $opacity) {
455 $shadow-color: if(type-of($color) == color, rgba($color, $opacity * 0.12), $color);
456
457 @return (
458 0: '0px 0px 0px 0px #{$shadow-color}',
459 1: '0px 1px 3px 0px #{$shadow-color}',
460 2: '0px 1px 5px 0px #{$shadow-color}',
461 3: '0px 1px 8px 0px #{$shadow-color}',
462 4: '0px 1px 10px 0px #{$shadow-color}',
463 5: '0px 1px 14px 0px #{$shadow-color}',
464 6: '0px 1px 18px 0px #{$shadow-color}',
465 7: '0px 2px 16px 1px #{$shadow-color}',
466 8: '0px 3px 14px 2px #{$shadow-color}',
467 9: '0px 3px 16px 2px #{$shadow-color}',
468 10: '0px 4px 18px 3px #{$shadow-color}',
469 11: '0px 4px 20px 3px #{$shadow-color}',
470 12: '0px 5px 22px 4px #{$shadow-color}',
471 13: '0px 5px 24px 4px #{$shadow-color}',
472 14: '0px 5px 26px 4px #{$shadow-color}',
473 15: '0px 6px 28px 5px #{$shadow-color}',
474 16: '0px 6px 30px 5px #{$shadow-color}',
475 17: '0px 6px 32px 5px #{$shadow-color}',
476 18: '0px 7px 34px 6px #{$shadow-color}',
477 19: '0px 7px 36px 6px #{$shadow-color}',
478 20: '0px 8px 38px 7px #{$shadow-color}',
479 21: '0px 8px 40px 7px #{$shadow-color}',
480 22: '0px 8px 42px 7px #{$shadow-color}',
481 23: '0px 9px 44px 8px #{$shadow-color}',
482 24: '0px 9px 46px 8px #{$shadow-color}'
483 );
484}
485
486// The default duration value for elevation transitions.
487$mat-elevation-transition-duration: 280ms !default;
488
489// The default easing value for elevation transitions.
490$mat-elevation-transition-timing-function: $mat-fast-out-slow-in-timing-function;
491
492// The default color for elevation shadows.
493$mat-elevation-color: black !default;
494
495// The default opacity scaling value for elevation shadows.
496$mat-elevation-opacity: 1 !default;
497
498// Prefix for elevation-related selectors.
499$mat-elevation-prefix: 'mat-elevation-z';
500
501// Applies the correct css rules to an element to give it the elevation specified by $zValue.
502// The $zValue must be between 0 and 24.
503@mixin mat-elevation($zValue, $color: $mat-elevation-color, $opacity: $mat-elevation-opacity) {
504 @if type-of($zValue) != number or not unitless($zValue) {
505 @error '$zValue must be a unitless number';
506 }
507 @if $zValue < 0 or $zValue > 24 {
508 @error '$zValue must be between 0 and 24';
509 }
510
511 box-shadow: #{map-get(_get-umbra-map($color, $opacity), $zValue)},
512 #{map-get(_get-penumbra-map($color, $opacity), $zValue)},
513 #{map-get(_get-ambient-map($color, $opacity), $zValue)};
514}
515
516// Applies the elevation to an element in a manner that allows
517// consumers to override it via the Material elevation classes.
518@mixin mat-overridable-elevation(
519 $zValue,
520 $color: $mat-elevation-color,
521 $opacity: $mat-elevation-opacity) {
522 &:not([class*='#{$mat-elevation-prefix}']) {
523 @include mat-elevation($zValue, $color, $opacity);
524 }
525}
526
527// Returns a string that can be used as the value for a transition property for elevation.
528// Calling this function directly is useful in situations where a component needs to transition
529// more than one property.
530//
531// .foo {
532// transition: mat-elevation-transition-property-value(), opacity 100ms ease;
533// }
534@function mat-elevation-transition-property-value(
535 $duration: $mat-elevation-transition-duration,
536 $easing: $mat-elevation-transition-timing-function) {
537 @return box-shadow #{$duration} #{$easing};
538}
539
540// Applies the correct css rules needed to have an element transition between elevations.
541// This mixin should be applied to elements whose elevation values will change depending on their
542// context (e.g. when active or disabled).
543//
544// NOTE(traviskaufman): Both this mixin and the above function use default parameters so they can
545// be used in the same way by clients.
546@mixin mat-elevation-transition(
547 $duration: $mat-elevation-transition-duration,
548 $easing: $mat-elevation-transition-timing-function) {
549 transition: mat-elevation-transition-property-value($duration, $easing);
550}
551
552
553@mixin mat-private-theme-elevation($zValue, $config, $opacity: $mat-elevation-opacity) {
554 $foreground: map-get($config, foreground);
555 $elevation-color: map-get($foreground, elevation);
556 $elevation-color-or-default: if($elevation-color == null, $mat-elevation-color, $elevation-color);
557
558 @include mat-elevation($zValue, $elevation-color-or-default, $opacity);
559}
560
561@mixin mat-private-theme-overridable-elevation($zValue, $config, $opacity: $mat-elevation-opacity) {
562 $foreground: map-get($config, foreground);
563 $elevation-color: map-get($foreground, elevation);
564 $elevation-color-or-default: if($elevation-color == null, $mat-elevation-color, $elevation-color);
565
566 @include mat-overridable-elevation($zValue, $elevation-color-or-default, $opacity);
567}
568
569// If the mat-animation-noop class is present on the components root element,
570// prevent non css animations from running.
571// NOTE: Currently this mixin should only be used with components that do not
572// have any projected content.
573@mixin mat-private-animation-noop() {
574 // @at-root is used to steps outside of the hierarchy of the scss rules. This is
575 // done to allow a class to be added to be added to base of the scss nesting
576 // context.
577 // For example:
578 // .my-root {
579 // .my-subclass {
580 // @include mat-private-animation-noop();
581 // }
582 // }
583 // results in:
584 // ._mat-animation-noopable.my-root .my-subclass { ... }
585 @at-root ._mat-animation-noopable#{&} {
586 transition: none;
587 animation: none;
588 @content;
589 }
590}
591
592// Color palettes from the Material Design spec.
593// See https://material.io/design/color/
594//
595// Contrast colors are hard-coded because it is too difficult (probably impossible) to
596// calculate them. These contrast colors are pulled from the public Material Design spec swatches.
597// While the contrast colors in the spec are not prescriptive, we use them for convenience.
598
599
600// @deprecated renamed to $dark-primary-text.
601// @breaking-change 8.0.0
602$black-87-opacity: rgba(black, 0.87);
603// @deprecated renamed to $light-primary-text.
604// @breaking-change 8.0.0
605$white-87-opacity: rgba(white, 0.87);
606// @deprecated use $dark-[secondary-text,disabled-text,dividers,focused] instead.
607// @breaking-change 8.0.0
608$black-12-opacity: rgba(black, 0.12);
609// @deprecated use $light-[secondary-text,disabled-text,dividers,focused] instead.
610// @breaking-change 8.0.0
611$white-12-opacity: rgba(white, 0.12);
612// @deprecated use $dark-[secondary-text,disabled-text,dividers,focused] instead.
613// @breaking-change 8.0.0
614$black-6-opacity: rgba(black, 0.06);
615// @deprecated use $light-[secondary-text,disabled-text,dividers,focused] instead.
616// @breaking-change 8.0.0
617$white-6-opacity: rgba(white, 0.06);
618
619$dark-primary-text: rgba(black, 0.87);
620$dark-secondary-text: rgba(black, 0.54);
621$dark-disabled-text: rgba(black, 0.38);
622$dark-dividers: rgba(black, 0.12);
623$dark-focused: rgba(black, 0.12);
624$light-primary-text: white;
625$light-secondary-text: rgba(white, 0.7);
626$light-disabled-text: rgba(white, 0.5);
627$light-dividers: rgba(white, 0.12);
628$light-focused: rgba(white, 0.12);
629
630$mat-red: (
631 50: #ffebee,
632 100: #ffcdd2,
633 200: #ef9a9a,
634 300: #e57373,
635 400: #ef5350,
636 500: #f44336,
637 600: #e53935,
638 700: #d32f2f,
639 800: #c62828,
640 900: #b71c1c,
641 A100: #ff8a80,
642 A200: #ff5252,
643 A400: #ff1744,
644 A700: #d50000,
645 contrast: (
646 50: $dark-primary-text,
647 100: $dark-primary-text,
648 200: $dark-primary-text,
649 300: $dark-primary-text,
650 400: $dark-primary-text,
651 500: $light-primary-text,
652 600: $light-primary-text,
653 700: $light-primary-text,
654 800: $light-primary-text,
655 900: $light-primary-text,
656 A100: $dark-primary-text,
657 A200: $light-primary-text,
658 A400: $light-primary-text,
659 A700: $light-primary-text,
660 )
661);
662
663$mat-pink: (
664 50: #fce4ec,
665 100: #f8bbd0,
666 200: #f48fb1,
667 300: #f06292,
668 400: #ec407a,
669 500: #e91e63,
670 600: #d81b60,
671 700: #c2185b,
672 800: #ad1457,
673 900: #880e4f,
674 A100: #ff80ab,
675 A200: #ff4081,
676 A400: #f50057,
677 A700: #c51162,
678 contrast: (
679 50: $dark-primary-text,
680 100: $dark-primary-text,
681 200: $dark-primary-text,
682 300: $dark-primary-text,
683 400: $dark-primary-text,
684 500: $light-primary-text,
685 600: $light-primary-text,
686 700: $light-primary-text,
687 800: $light-primary-text,
688 900: $light-primary-text,
689 A100: $dark-primary-text,
690 A200: $light-primary-text,
691 A400: $light-primary-text,
692 A700: $light-primary-text,
693 )
694);
695
696$mat-purple: (
697 50: #f3e5f5,
698 100: #e1bee7,
699 200: #ce93d8,
700 300: #ba68c8,
701 400: #ab47bc,
702 500: #9c27b0,
703 600: #8e24aa,
704 700: #7b1fa2,
705 800: #6a1b9a,
706 900: #4a148c,
707 A100: #ea80fc,
708 A200: #e040fb,
709 A400: #d500f9,
710 A700: #aa00ff,
711 contrast: (
712 50: $dark-primary-text,
713 100: $dark-primary-text,
714 200: $dark-primary-text,
715 300: $light-primary-text,
716 400: $light-primary-text,
717 500: $light-primary-text,
718 600: $light-primary-text,
719 700: $light-primary-text,
720 800: $light-primary-text,
721 900: $light-primary-text,
722 A100: $dark-primary-text,
723 A200: $light-primary-text,
724 A400: $light-primary-text,
725 A700: $light-primary-text,
726 )
727);
728
729$mat-deep-purple: (
730 50: #ede7f6,
731 100: #d1c4e9,
732 200: #b39ddb,
733 300: #9575cd,
734 400: #7e57c2,
735 500: #673ab7,
736 600: #5e35b1,
737 700: #512da8,
738 800: #4527a0,
739 900: #311b92,
740 A100: #b388ff,
741 A200: #7c4dff,
742 A400: #651fff,
743 A700: #6200ea,
744 contrast: (
745 50: $dark-primary-text,
746 100: $dark-primary-text,
747 200: $dark-primary-text,
748 300: $light-primary-text,
749 400: $light-primary-text,
750 500: $light-primary-text,
751 600: $light-primary-text,
752 700: $light-primary-text,
753 800: $light-primary-text,
754 900: $light-primary-text,
755 A100: $dark-primary-text,
756 A200: $light-primary-text,
757 A400: $light-primary-text,
758 A700: $light-primary-text,
759 )
760);
761
762$mat-indigo: (
763 50: #e8eaf6,
764 100: #c5cae9,
765 200: #9fa8da,
766 300: #7986cb,
767 400: #5c6bc0,
768 500: #3f51b5,
769 600: #3949ab,
770 700: #303f9f,
771 800: #283593,
772 900: #1a237e,
773 A100: #8c9eff,
774 A200: #536dfe,
775 A400: #3d5afe,
776 A700: #304ffe,
777 contrast: (
778 50: $dark-primary-text,
779 100: $dark-primary-text,
780 200: $dark-primary-text,
781 300: $light-primary-text,
782 400: $light-primary-text,
783 500: $light-primary-text,
784 600: $light-primary-text,
785 700: $light-primary-text,
786 800: $light-primary-text,
787 900: $light-primary-text,
788 A100: $dark-primary-text,
789 A200: $light-primary-text,
790 A400: $light-primary-text,
791 A700: $light-primary-text,
792 )
793);
794
795$mat-blue: (
796 50: #e3f2fd,
797 100: #bbdefb,
798 200: #90caf9,
799 300: #64b5f6,
800 400: #42a5f5,
801 500: #2196f3,
802 600: #1e88e5,
803 700: #1976d2,
804 800: #1565c0,
805 900: #0d47a1,
806 A100: #82b1ff,
807 A200: #448aff,
808 A400: #2979ff,
809 A700: #2962ff,
810 contrast: (
811 50: $dark-primary-text,
812 100: $dark-primary-text,
813 200: $dark-primary-text,
814 300: $dark-primary-text,
815 400: $dark-primary-text,
816 500: $light-primary-text,
817 600: $light-primary-text,
818 700: $light-primary-text,
819 800: $light-primary-text,
820 900: $light-primary-text,
821 A100: $dark-primary-text,
822 A200: $light-primary-text,
823 A400: $light-primary-text,
824 A700: $light-primary-text,
825 )
826);
827
828$mat-light-blue: (
829 50: #e1f5fe,
830 100: #b3e5fc,
831 200: #81d4fa,
832 300: #4fc3f7,
833 400: #29b6f6,
834 500: #03a9f4,
835 600: #039be5,
836 700: #0288d1,
837 800: #0277bd,
838 900: #01579b,
839 A100: #80d8ff,
840 A200: #40c4ff,
841 A400: #00b0ff,
842 A700: #0091ea,
843 contrast: (
844 50: $dark-primary-text,
845 100: $dark-primary-text,
846 200: $dark-primary-text,
847 300: $dark-primary-text,
848 400: $dark-primary-text,
849 500: $light-primary-text,
850 600: $light-primary-text,
851 700: $light-primary-text,
852 800: $light-primary-text,
853 900: $light-primary-text,
854 A100: $dark-primary-text,
855 A200: $dark-primary-text,
856 A400: $dark-primary-text,
857 A700: $light-primary-text,
858 )
859);
860
861$mat-cyan: (
862 50: #e0f7fa,
863 100: #b2ebf2,
864 200: #80deea,
865 300: #4dd0e1,
866 400: #26c6da,
867 500: #00bcd4,
868 600: #00acc1,
869 700: #0097a7,
870 800: #00838f,
871 900: #006064,
872 A100: #84ffff,
873 A200: #18ffff,
874 A400: #00e5ff,
875 A700: #00b8d4,
876 contrast: (
877 50: $dark-primary-text,
878 100: $dark-primary-text,
879 200: $dark-primary-text,
880 300: $dark-primary-text,
881 400: $dark-primary-text,
882 500: $light-primary-text,
883 600: $light-primary-text,
884 700: $light-primary-text,
885 800: $light-primary-text,
886 900: $light-primary-text,
887 A100: $dark-primary-text,
888 A200: $dark-primary-text,
889 A400: $dark-primary-text,
890 A700: $dark-primary-text,
891 )
892);
893
894$mat-teal: (
895 50: #e0f2f1,
896 100: #b2dfdb,
897 200: #80cbc4,
898 300: #4db6ac,
899 400: #26a69a,
900 500: #009688,
901 600: #00897b,
902 700: #00796b,
903 800: #00695c,
904 900: #004d40,
905 A100: #a7ffeb,
906 A200: #64ffda,
907 A400: #1de9b6,
908 A700: #00bfa5,
909 contrast: (
910 50: $dark-primary-text,
911 100: $dark-primary-text,
912 200: $dark-primary-text,
913 300: $dark-primary-text,
914 400: $dark-primary-text,
915 500: $light-primary-text,
916 600: $light-primary-text,
917 700: $light-primary-text,
918 800: $light-primary-text,
919 900: $light-primary-text,
920 A100: $dark-primary-text,
921 A200: $dark-primary-text,
922 A400: $dark-primary-text,
923 A700: $dark-primary-text,
924 )
925);
926
927$mat-green: (
928 50: #e8f5e9,
929 100: #c8e6c9,
930 200: #a5d6a7,
931 300: #81c784,
932 400: #66bb6a,
933 500: #4caf50,
934 600: #43a047,
935 700: #388e3c,
936 800: #2e7d32,
937 900: #1b5e20,
938 A100: #b9f6ca,
939 A200: #69f0ae,
940 A400: #00e676,
941 A700: #00c853,
942 contrast: (
943 50: $dark-primary-text,
944 100: $dark-primary-text,
945 200: $dark-primary-text,
946 300: $dark-primary-text,
947 400: $dark-primary-text,
948 500: $dark-primary-text,
949 600: $light-primary-text,
950 700: $light-primary-text,
951 800: $light-primary-text,
952 900: $light-primary-text,
953 A100: $dark-primary-text,
954 A200: $dark-primary-text,
955 A400: $dark-primary-text,
956 A700: $dark-primary-text,
957 )
958);
959
960$mat-light-green: (
961 50: #f1f8e9,
962 100: #dcedc8,
963 200: #c5e1a5,
964 300: #aed581,
965 400: #9ccc65,
966 500: #8bc34a,
967 600: #7cb342,
968 700: #689f38,
969 800: #558b2f,
970 900: #33691e,
971 A100: #ccff90,
972 A200: #b2ff59,
973 A400: #76ff03,
974 A700: #64dd17,
975 contrast: (
976 50: $dark-primary-text,
977 100: $dark-primary-text,
978 200: $dark-primary-text,
979 300: $dark-primary-text,
980 400: $dark-primary-text,
981 500: $dark-primary-text,
982 600: $dark-primary-text,
983 700: $light-primary-text,
984 800: $light-primary-text,
985 900: $light-primary-text,
986 A100: $dark-primary-text,
987 A200: $dark-primary-text,
988 A400: $dark-primary-text,
989 A700: $dark-primary-text,
990 )
991);
992
993$mat-lime: (
994 50: #f9fbe7,
995 100: #f0f4c3,
996 200: #e6ee9c,
997 300: #dce775,
998 400: #d4e157,
999 500: #cddc39,
1000 600: #c0ca33,
1001 700: #afb42b,
1002 800: #9e9d24,
1003 900: #827717,
1004 A100: #f4ff81,
1005 A200: #eeff41,
1006 A400: #c6ff00,
1007 A700: #aeea00,
1008 contrast: (
1009 50: $dark-primary-text,
1010 100: $dark-primary-text,
1011 200: $dark-primary-text,
1012 300: $dark-primary-text,
1013 400: $dark-primary-text,
1014 500: $dark-primary-text,
1015 600: $dark-primary-text,
1016 700: $dark-primary-text,
1017 800: $dark-primary-text,
1018 900: $light-primary-text,
1019 A100: $dark-primary-text,
1020 A200: $dark-primary-text,
1021 A400: $dark-primary-text,
1022 A700: $dark-primary-text,
1023 )
1024);
1025
1026$mat-yellow: (
1027 50: #fffde7,
1028 100: #fff9c4,
1029 200: #fff59d,
1030 300: #fff176,
1031 400: #ffee58,
1032 500: #ffeb3b,
1033 600: #fdd835,
1034 700: #fbc02d,
1035 800: #f9a825,
1036 900: #f57f17,
1037 A100: #ffff8d,
1038 A200: #ffff00,
1039 A400: #ffea00,
1040 A700: #ffd600,
1041 contrast: (
1042 50: $dark-primary-text,
1043 100: $dark-primary-text,
1044 200: $dark-primary-text,
1045 300: $dark-primary-text,
1046 400: $dark-primary-text,
1047 500: $dark-primary-text,
1048 600: $dark-primary-text,
1049 700: $dark-primary-text,
1050 800: $dark-primary-text,
1051 900: $dark-primary-text,
1052 A100: $dark-primary-text,
1053 A200: $dark-primary-text,
1054 A400: $dark-primary-text,
1055 A700: $dark-primary-text,
1056 )
1057);
1058
1059$mat-amber: (
1060 50: #fff8e1,
1061 100: #ffecb3,
1062 200: #ffe082,
1063 300: #ffd54f,
1064 400: #ffca28,
1065 500: #ffc107,
1066 600: #ffb300,
1067 700: #ffa000,
1068 800: #ff8f00,
1069 900: #ff6f00,
1070 A100: #ffe57f,
1071 A200: #ffd740,
1072 A400: #ffc400,
1073 A700: #ffab00,
1074 contrast: (
1075 50: $dark-primary-text,
1076 100: $dark-primary-text,
1077 200: $dark-primary-text,
1078 300: $dark-primary-text,
1079 400: $dark-primary-text,
1080 500: $dark-primary-text,
1081 600: $dark-primary-text,
1082 700: $dark-primary-text,
1083 800: $dark-primary-text,
1084 900: $dark-primary-text,
1085 A100: $dark-primary-text,
1086 A200: $dark-primary-text,
1087 A400: $dark-primary-text,
1088 A700: $dark-primary-text,
1089 )
1090);
1091
1092$mat-orange: (
1093 50: #fff3e0,
1094 100: #ffe0b2,
1095 200: #ffcc80,
1096 300: #ffb74d,
1097 400: #ffa726,
1098 500: #ff9800,
1099 600: #fb8c00,
1100 700: #f57c00,
1101 800: #ef6c00,
1102 900: #e65100,
1103 A100: #ffd180,
1104 A200: #ffab40,
1105 A400: #ff9100,
1106 A700: #ff6d00,
1107 contrast: (
1108 50: $dark-primary-text,
1109 100: $dark-primary-text,
1110 200: $dark-primary-text,
1111 300: $dark-primary-text,
1112 400: $dark-primary-text,
1113 500: $dark-primary-text,
1114 600: $dark-primary-text,
1115 700: $dark-primary-text,
1116 800: $light-primary-text,
1117 900: $light-primary-text,
1118 A100: $dark-primary-text,
1119 A200: $dark-primary-text,
1120 A400: $dark-primary-text,
1121 A700: black,
1122 )
1123);
1124
1125$mat-deep-orange: (
1126 50: #fbe9e7,
1127 100: #ffccbc,
1128 200: #ffab91,
1129 300: #ff8a65,
1130 400: #ff7043,
1131 500: #ff5722,
1132 600: #f4511e,
1133 700: #e64a19,
1134 800: #d84315,
1135 900: #bf360c,
1136 A100: #ff9e80,
1137 A200: #ff6e40,
1138 A400: #ff3d00,
1139 A700: #dd2c00,
1140 contrast: (
1141 50: $dark-primary-text,
1142 100: $dark-primary-text,
1143 200: $dark-primary-text,
1144 300: $dark-primary-text,
1145 400: $dark-primary-text,
1146 500: $light-primary-text,
1147 600: $light-primary-text,
1148 700: $light-primary-text,
1149 800: $light-primary-text,
1150 900: $light-primary-text,
1151 A100: $dark-primary-text,
1152 A200: $dark-primary-text,
1153 A400: $light-primary-text,
1154 A700: $light-primary-text,
1155 )
1156);
1157
1158$mat-brown: (
1159 50: #efebe9,
1160 100: #d7ccc8,
1161 200: #bcaaa4,
1162 300: #a1887f,
1163 400: #8d6e63,
1164 500: #795548,
1165 600: #6d4c41,
1166 700: #5d4037,
1167 800: #4e342e,
1168 900: #3e2723,
1169 A100: #d7ccc8,
1170 A200: #bcaaa4,
1171 A400: #8d6e63,
1172 A700: #5d4037,
1173 contrast: (
1174 50: $dark-primary-text,
1175 100: $dark-primary-text,
1176 200: $dark-primary-text,
1177 300: $light-primary-text,
1178 400: $light-primary-text,
1179 500: $light-primary-text,
1180 600: $light-primary-text,
1181 700: $light-primary-text,
1182 800: $light-primary-text,
1183 900: $light-primary-text,
1184 A100: $dark-primary-text,
1185 A200: $dark-primary-text,
1186 A400: $light-primary-text,
1187 A700: $light-primary-text,
1188 )
1189);
1190
1191$mat-grey: (
1192 50: #fafafa,
1193 100: #f5f5f5,
1194 200: #eeeeee,
1195 300: #e0e0e0,
1196 400: #bdbdbd,
1197 500: #9e9e9e,
1198 600: #757575,
1199 700: #616161,
1200 800: #424242,
1201 900: #212121,
1202 A100: #ffffff,
1203 A200: #eeeeee,
1204 A400: #bdbdbd,
1205 A700: #616161,
1206 contrast: (
1207 50: $dark-primary-text,
1208 100: $dark-primary-text,
1209 200: $dark-primary-text,
1210 300: $dark-primary-text,
1211 400: $dark-primary-text,
1212 500: $dark-primary-text,
1213 600: $light-primary-text,
1214 700: $light-primary-text,
1215 800: $light-primary-text,
1216 900: $light-primary-text,
1217 A100: $dark-primary-text,
1218 A200: $dark-primary-text,
1219 A400: $dark-primary-text,
1220 A700: $light-primary-text,
1221 )
1222);
1223
1224// Alias for alternate spelling.
1225$mat-gray: $mat-grey;
1226
1227$mat-blue-grey: (
1228 50: #eceff1,
1229 100: #cfd8dc,
1230 200: #b0bec5,
1231 300: #90a4ae,
1232 400: #78909c,
1233 500: #607d8b,
1234 600: #546e7a,
1235 700: #455a64,
1236 800: #37474f,
1237 900: #263238,
1238 A100: #cfd8dc,
1239 A200: #b0bec5,
1240 A400: #78909c,
1241 A700: #455a64,
1242 contrast: (
1243 50: $dark-primary-text,
1244 100: $dark-primary-text,
1245 200: $dark-primary-text,
1246 300: $dark-primary-text,
1247 400: $light-primary-text,
1248 500: $light-primary-text,
1249 600: $light-primary-text,
1250 700: $light-primary-text,
1251 800: $light-primary-text,
1252 900: $light-primary-text,
1253 A100: $dark-primary-text,
1254 A200: $dark-primary-text,
1255 A400: $light-primary-text,
1256 A700: $light-primary-text,
1257 )
1258);
1259
1260// Alias for alternate spelling.
1261$mat-blue-gray: $mat-blue-grey;
1262
1263
1264// Background palette for light themes.
1265$mat-light-theme-background: (
1266 status-bar: map-get($mat-grey, 300),
1267 app-bar: map-get($mat-grey, 100),
1268 background: map-get($mat-grey, 50),
1269 hover: rgba(black, 0.04), // TODO(kara): check style with Material Design UX
1270 card: white,
1271 dialog: white,
1272 disabled-button: rgba(black, 0.12),
1273 raised-button: white,
1274 focused-button: $dark-focused,
1275 selected-button: map-get($mat-grey, 300),
1276 selected-disabled-button: map-get($mat-grey, 400),
1277 disabled-button-toggle: map-get($mat-grey, 200),
1278 unselected-chip: map-get($mat-grey, 300),
1279 disabled-list-option: map-get($mat-grey, 200),
1280 tooltip: map-get($mat-grey, 700),
1281);
1282
1283// Background palette for dark themes.
1284$mat-dark-theme-background: (
1285 status-bar: black,
1286 app-bar: map-get($mat-grey, 900),
1287 background: #303030,
1288 hover: rgba(white, 0.04), // TODO(kara): check style with Material Design UX
1289 card: map-get($mat-grey, 800),
1290 dialog: map-get($mat-grey, 800),
1291 disabled-button: rgba(white, 0.12),
1292 raised-button: map-get($mat-grey, 800),
1293 focused-button: $light-focused,
1294 selected-button: map-get($mat-grey, 900),
1295 selected-disabled-button: map-get($mat-grey, 800),
1296 disabled-button-toggle: black,
1297 unselected-chip: map-get($mat-grey, 700),
1298 disabled-list-option: black,
1299 tooltip: map-get($mat-grey, 700),
1300);
1301
1302// Foreground palette for light themes.
1303$mat-light-theme-foreground: (
1304 base: black,
1305 divider: $dark-dividers,
1306 dividers: $dark-dividers,
1307 disabled: $dark-disabled-text,
1308 disabled-button: rgba(black, 0.26),
1309 disabled-text: $dark-disabled-text,
1310 elevation: black,
1311 hint-text: $dark-disabled-text,
1312 secondary-text: $dark-secondary-text,
1313 icon: rgba(black, 0.54),
1314 icons: rgba(black, 0.54),
1315 text: rgba(black, 0.87),
1316 slider-min: rgba(black, 0.87),
1317 slider-off: rgba(black, 0.26),
1318 slider-off-active: rgba(black, 0.38),
1319);
1320
1321// Foreground palette for dark themes.
1322$mat-dark-theme-foreground: (
1323 base: white,
1324 divider: $light-dividers,
1325 dividers: $light-dividers,
1326 disabled: $light-disabled-text,
1327 disabled-button: rgba(white, 0.3),
1328 disabled-text: $light-disabled-text,
1329 elevation: black,
1330 hint-text: $light-disabled-text,
1331 secondary-text: $light-secondary-text,
1332 icon: white,
1333 icons: white,
1334 text: white,
1335 slider-min: white,
1336 slider-off: rgba(white, 0.3),
1337 slider-off-active: rgba(white, 0.3),
1338);
1339
1340// Note that this file is called `private`, because the APIs in it aren't public yet.
1341// Once they're made available, the code should be moved out into an `index.scss`.
1342
1343// Taken from mat-density with small modifications to not rely on the new Sass module
1344// system, and to support arbitrary properties in a density configuration.
1345// https://github.com/material-components/material-components-web/blob/master/packages/mdc-density
1346
1347$_mat-density-interval: 4px !default;
1348$_mat-density-minimum-scale: minimum !default;
1349$_mat-density-maximum-scale: maximum !default;
1350$_mat-density-supported-scales: (default, minimum, maximum) !default;
1351$_mat-density-default-scale: 0 !default;
1352
1353// Whether density should be generated at root. This will be temporarily set to `true`
1354// whenever density styles for legacy themes are generated.
1355$mat-private-density-generate-at-root: false;
1356// Whether density styles should be generated. This will be temporarily set to `false` if
1357// duplicate density styles for a legacy theme would be generated. For legacy themes,
1358// we always generate the default density **only once** at root.
1359$mat-private-density-generate-styles: true;
1360
1361// Mixin that can be used to wrap density styles of given components. The mixin will
1362// move the density styles to root if the `$mat-private-density-generate-at-root` global variable
1363// is set. If `$mat-private-density-generate-styles` is set to `false`, generation of density
1364// styles wrapped in this mixin is skipped. This mixin exists to improve backwards compatibility
1365// of the new theming API where density styles are included as part of themes. Previously,
1366// density styles of components were part of their base styles. With the new API, they are
1367// part of the theming system. The `<..>-theme` mixins generate density by default unless
1368// the density configuration is explicitly specified as per new API. This means, that projects
1369// using `<..>-theme` mixins for separate themes (like `.dark-theme`) will cause duplicate
1370// density styles. This is breaking as it increases specificity of density styles. This mixin
1371// provides an API to control generation of density styles so that we can ensure they are only
1372// created *once* and at root.
1373@mixin mat-private-density-legacy-compatibility() {
1374 @if $mat-private-density-generate-styles and $mat-private-density-generate-at-root {
1375 @at-root {
1376 @content;
1377 }
1378 }
1379 @else if $mat-private-density-generate-styles {
1380 @content;
1381 }
1382}
1383
1384@function mat-private-density-prop-value($density-config, $density-scale, $property-name) {
1385 @if (type-of($density-scale) == 'string' and
1386 index($list: $_mat-density-supported-scales, $value: $density-scale) == null) {
1387 @error 'mat-density: Supported density scales #{$_mat-density-supported-scales}, ' +
1388 'but received #{$density-scale}.';
1389 }
1390
1391 $value: null;
1392 $property-scale-map: map-get($density-config, $property-name);
1393
1394 @if map-has-key($property-scale-map, $density-scale) {
1395 $value: map-get($property-scale-map, $density-scale);
1396 }
1397 @else {
1398 $value: map-get($property-scale-map, default) + $density-scale * $_mat-density-interval;
1399 }
1400
1401 $min-value: map-get($property-scale-map, $_mat-density-minimum-scale);
1402 $max-value: map-get($property-scale-map, $_mat-density-maximum-scale);
1403
1404 @if ($value < $min-value or $value > $max-value) {
1405 @error 'mat-density: #{$property-name} must be between #{$min-value} and ' +
1406 '#{$max-value} (inclusive), but received #{$value}.';
1407 }
1408
1409 @return $value;
1410}
1411
1412
1413// Whether duplication warnings should be disabled. Warnings enabled by default.
1414$mat-theme-ignore-duplication-warnings: false !default;
1415
1416// Whether density should be generated by default.
1417$_mat-theme-generate-default-density: true !default;
1418
1419// Warning that will be printed if duplicated styles are generated by a theme.
1420$_mat-theme-duplicate-warning: 'Read more about how style duplication can be avoided in a ' +
1421 'dedicated guide. https://github.com/angular/components/blob/master/guides/duplicate-theming-styles.md';
1422
1423// These variable are not intended to be overridden externally. They use `!default` to
1424// avoid being reset every time this file is imported.
1425$_mat-theme-emitted-color: () !default;
1426$_mat-theme-emitted-typography: () !default;
1427$_mat-theme-emitted-density: () !default;
1428
1429// For a given hue in a palette, return the contrast color from the map of contrast palettes.
1430// @param $palette
1431// @param $hue
1432@function mat-contrast($palette, $hue) {
1433 @return map-get(map-get($palette, contrast), $hue);
1434}
1435
1436
1437// Creates a map of hues to colors for a theme. This is used to define a theme palette in terms
1438// of the Material Design hues.
1439// @param $base-palette
1440// @param $default
1441// @param $lighter
1442// @param $darker
1443// @param $text
1444@function mat-palette($base-palette, $default: 500, $lighter: 100, $darker: 700, $text: $default) {
1445 $result: map-merge($base-palette, (
1446 default: map-get($base-palette, $default),
1447 lighter: map-get($base-palette, $lighter),
1448 darker: map-get($base-palette, $darker),
1449 text: map-get($base-palette, $text),
1450
1451 default-contrast: mat-contrast($base-palette, $default),
1452 lighter-contrast: mat-contrast($base-palette, $lighter),
1453 darker-contrast: mat-contrast($base-palette, $darker)
1454 ));
1455
1456 // For each hue in the palette, add a "-contrast" color to the map.
1457 @each $hue, $color in $base-palette {
1458 $result: map-merge($result, (
1459 '#{$hue}-contrast': mat-contrast($base-palette, $hue)
1460 ));
1461 }
1462
1463 @return $result;
1464}
1465
1466
1467// Gets a color from a theme palette (the output of mat-palette).
1468// The hue can be one of the standard values (500, A400, etc.), one of the three preconfigured
1469// hues (default, lighter, darker), or any of the aforementioned prefixed with "-contrast".
1470//
1471// @param $palette The theme palette (output of mat-palette).
1472// @param $hue The hue from the palette to use. If this is a value between 0 and 1, it will
1473// be treated as opacity.
1474// @param $opacity The alpha channel value for the color.
1475@function mat-color($palette, $hue: default, $opacity: null) {
1476 // If hueKey is a number between zero and one, then it actually contains an
1477 // opacity value, so recall this function with the default hue and that given opacity.
1478 @if type-of($hue) == number and $hue >= 0 and $hue <= 1 {
1479 @return mat-color($palette, default, $hue);
1480 }
1481
1482 $color: map-get($palette, $hue);
1483
1484 @if (type-of($color) != color) {
1485 // If the $color resolved to something different from a color (e.g. a CSS variable),
1486 // we can't apply the opacity anyway so we return the value as is, otherwise Sass can
1487 // throw an error or output something invalid.
1488 @return $color;
1489 }
1490
1491 @return rgba($color, if($opacity == null, opacity($color), $opacity));
1492}
1493
1494// Validates the specified theme by ensuring that the optional color config defines
1495// a primary, accent and warn palette. Returns the theme if no failures were found.
1496@function _mat-validate-theme($theme) {
1497 @if map-get($theme, color) {
1498 $color: map-get($theme, color);
1499 @if not map-get($color, primary) {
1500 @error 'Theme does not define a valid "primary" palette.';
1501 }
1502 @else if not map-get($color, accent) {
1503 @error 'Theme does not define a valid "accent" palette.';
1504 }
1505 @else if not map-get($color, warn) {
1506 @error 'Theme does not define a valid "warn" palette.';
1507 }
1508 }
1509 @return $theme;
1510}
1511
1512// Creates a light-themed color configuration from the specified
1513// primary, accent and warn palettes.
1514@function _mat-create-light-color-config($primary, $accent, $warn: null) {
1515 @return (
1516 primary: $primary,
1517 accent: $accent,
1518 warn: if($warn != null, $warn, mat-palette($mat-red)),
1519 is-dark: false,
1520 foreground: $mat-light-theme-foreground,
1521 background: $mat-light-theme-background,
1522 );
1523}
1524
1525// Creates a dark-themed color configuration from the specified
1526// primary, accent and warn palettes.
1527@function _mat-create-dark-color-config($primary, $accent, $warn: null) {
1528 @return (
1529 primary: $primary,
1530 accent: $accent,
1531 warn: if($warn != null, $warn, mat-palette($mat-red)),
1532 is-dark: true,
1533 foreground: $mat-dark-theme-foreground,
1534 background: $mat-dark-theme-background,
1535 );
1536}
1537
1538// Creates a container object for a light theme to be given to individual component theme mixins.
1539// TODO: Remove legacy API and rename `$primary` to `$config`. Currently it cannot be renamed
1540// as it would break existing apps that set the parameter by name.
1541@function mat-light-theme($primary, $accent: null, $warn: mat-palette($mat-red)) {
1542 // This function creates a container object for the individual component theme mixins. Consumers
1543 // can construct such an object by calling this function, or by building the object manually.
1544 // There are two possible ways to invoke this function in order to create such an object:
1545 //
1546 // (1) Passing in a map that holds optional configurations for individual parts of the
1547 // theming system. For `color` configurations, the function only expects the palettes
1548 // for `primary` and `accent` (and optionally `warn`). The function will expand the
1549 // shorthand into an actual configuration that can be consumed in `-color` mixins.
1550 // (2) Legacy pattern: Passing in the palettes as parameters. This is not as flexible
1551 // as passing in a configuration map because only the `color` system can be configured.
1552 //
1553 // If the legacy pattern is used, we generate a container object only with a light-themed
1554 // configuration for the `color` theming part.
1555 @if $accent != null {
1556 @return mat-private-create-backwards-compatibility-theme(_mat-validate-theme((
1557 _is-legacy-theme: true,
1558 color: _mat-create-light-color-config($primary, $accent, $warn),
1559 )));
1560 }
1561 // If the map pattern is used (1), we just pass-through the configurations for individual
1562 // parts of the theming system, but update the `color` configuration if set. As explained
1563 // above, the color shorthand will be expanded to an actual light-themed color configuration.
1564 $result: $primary;
1565 @if map-get($primary, color) {
1566 $color-settings: map-get($primary, color);
1567 $primary: map-get($color-settings, primary);
1568 $accent: map-get($color-settings, accent);
1569 $warn: map-get($color-settings, warn);
1570 $result: map-merge($result, (color: _mat-create-light-color-config($primary, $accent, $warn)));
1571 }
1572 @return mat-private-create-backwards-compatibility-theme(_mat-validate-theme($result));
1573}
1574
1575// Creates a container object for a dark theme to be given to individual component theme mixins.
1576// TODO: Remove legacy API and rename `$primary` to `$config`. Currently it cannot be renamed
1577// as it would break existing apps that set the parameter by name.
1578@function mat-dark-theme($primary, $accent: null, $warn: mat-palette($mat-red)) {
1579 // This function creates a container object for the individual component theme mixins. Consumers
1580 // can construct such an object by calling this function, or by building the object manually.
1581 // There are two possible ways to invoke this function in order to create such an object:
1582 //
1583 // (1) Passing in a map that holds optional configurations for individual parts of the
1584 // theming system. For `color` configurations, the function only expects the palettes
1585 // for `primary` and `accent` (and optionally `warn`). The function will expand the
1586 // shorthand into an actual configuration that can be consumed in `-color` mixins.
1587 // (2) Legacy pattern: Passing in the palettes as parameters. This is not as flexible
1588 // as passing in a configuration map because only the `color` system can be configured.
1589 //
1590 // If the legacy pattern is used, we generate a container object only with a dark-themed
1591 // configuration for the `color` theming part.
1592 @if $accent != null {
1593 @return mat-private-create-backwards-compatibility-theme(_mat-validate-theme((
1594 _is-legacy-theme: true,
1595 color: _mat-create-dark-color-config($primary, $accent, $warn),
1596 )));
1597 }
1598 // If the map pattern is used (1), we just pass-through the configurations for individual
1599 // parts of the theming system, but update the `color` configuration if set. As explained
1600 // above, the color shorthand will be expanded to an actual dark-themed color configuration.
1601 $result: $primary;
1602 @if map-get($primary, color) {
1603 $color-settings: map-get($primary, color);
1604 $primary: map-get($color-settings, primary);
1605 $accent: map-get($color-settings, accent);
1606 $warn: map-get($color-settings, warn);
1607 $result: map-merge($result, (color: _mat-create-dark-color-config($primary, $accent, $warn)));
1608 }
1609 @return mat-private-create-backwards-compatibility-theme(_mat-validate-theme($result));
1610}
1611
1612/// Gets the color configuration from the given theme or configuration.
1613@function mat-get-color-config($theme, $default: null) {
1614 // If a configuration has been passed, return the config directly.
1615 @if not mat-private-is-theme-object($theme) {
1616 @return $theme;
1617 }
1618 // If the theme has been constructed through the legacy theming API, we use the theme object
1619 // as color configuration instead of the dedicated `color` property. We do this because for
1620 // backwards compatibility, we copied the color configuration from `$theme.color` to `$theme`.
1621 // Hence developers could customize the colors at top-level and want to respect these changes
1622 // TODO: Remove when legacy theming API is removed.
1623 @if mat-private-is-legacy-constructed-theme($theme) {
1624 @return $theme;
1625 }
1626 @if map-has-key($theme, color) {
1627 @return map-get($theme, color);
1628 }
1629 @return $default;
1630}
1631
1632/// Gets the density configuration from the given theme or configuration.
1633@function mat-get-density-config($theme-or-config, $default: 0) {
1634 // If a configuration has been passed, return the config directly.
1635 @if not mat-private-is-theme-object($theme-or-config) {
1636 @return $theme-or-config;
1637 }
1638 // In case a theme has been passed, extract the configuration if present,
1639 // or fall back to the default density config.
1640 @if map-has-key($theme-or-config, density) {
1641 @return map-get($theme-or-config, density);
1642 }
1643 @return $default;
1644}
1645
1646/// Gets the typography configuration from the given theme or configuration.
1647/// For backwards compatibility, typography is not included by default.
1648@function mat-get-typography-config($theme-or-config, $default: null) {
1649 // If a configuration has been passed, return the config directly.
1650 @if not mat-private-is-theme-object($theme-or-config) {
1651 @return $theme-or-config;
1652 }
1653 // In case a theme has been passed, extract the configuration if present,
1654 // or fall back to the default typography config.
1655 @if (map-has-key($theme-or-config, typography)) {
1656 @return map-get($theme-or-config, typography);
1657 }
1658 @return $default;
1659}
1660
1661
1662//
1663// Private APIs
1664//
1665
1666// Checks if configurations that have been declared in the given theme have been generated
1667// before. If so, warnings will be reported. This should notify developers in case duplicate
1668// styles are accidentally generated due to wrong usage of the all-theme mixins.
1669//
1670// Additionally, this mixin controls the default value for the density configuration. By
1671// default, density styles are generated at scale zero. If the same density styles would be
1672// generated a second time though, the default value will change to avoid duplicate styles.
1673//
1674// The mixin keeps track of all configurations in a list that is scoped to the specified
1675// id. This is necessary because a given theme can be passed to multiple disjoint theme mixins
1676// (e.g. `angular-material-theme` and `angular-material-mdc-theme`) without causing any
1677// style duplication.
1678@mixin mat-private-check-duplicate-theme-styles($theme-or-color-config, $id) {
1679 $theme: mat-private-legacy-get-theme($theme-or-color-config);
1680 $color-config: mat-get-color-config($theme);
1681 $density-config: mat-get-density-config($theme);
1682 $typography-config: mat-get-typography-config($theme);
1683 // Lists of previous `color`, `density` and `typography` configurations.
1684 $previous-color: map-get($_mat-theme-emitted-color, $id) or ();
1685 $previous-typography: map-get($_mat-theme-emitted-typography, $id) or ();
1686 $previous-density: map-get($_mat-theme-emitted-density, $id) or ();
1687 // Whether duplicate legacy density styles would be generated.
1688 $duplicate-legacy-density: false;
1689
1690 // Check if the color configuration has been generated before.
1691 @if $color-config != null {
1692 @if index($previous-color, $color-config) != null and
1693 not $mat-theme-ignore-duplication-warnings {
1694 @warn 'The same color styles are generated multiple times. ' +
1695 $_mat-theme-duplicate-warning;
1696 }
1697 $previous-color: append($previous-color, $color-config);
1698 }
1699
1700 // Check if the typography configuration has been generated before.
1701 @if $typography-config != null {
1702 @if index($previous-typography, $typography-config) != null and
1703 not $mat-theme-ignore-duplication-warnings {
1704 @warn 'The same typography styles are generated multiple times. ' +
1705 $_mat-theme-duplicate-warning;
1706 }
1707 $previous-typography: append($previous-typography, $typography-config);
1708 }
1709
1710 // Check if the density configuration has been generated before.
1711 @if $density-config != null {
1712 @if index($previous-density, $density-config) != null {
1713 // Only report a warning if density styles would be duplicated for non-legacy theme
1714 // definitions. For legacy themes, we have compatibility logic that avoids duplication
1715 // of default density styles. We don't want to report a warning in those cases.
1716 @if mat-private-is-legacy-constructed-theme($theme) {
1717 $duplicate-legacy-density: true;
1718 }
1719 @else if not $mat-theme-ignore-duplication-warnings {
1720 @warn 'The same density styles are generated multiple times. ' +
1721 $_mat-theme-duplicate-warning;
1722 }
1723 }
1724 $previous-density: append($previous-density, $density-config);
1725 }
1726
1727 $_mat-theme-emitted-color: map-merge(
1728 $_mat-theme-emitted-color, ($id: $previous-color)) !global;
1729 $_mat-theme-emitted-density: map-merge(
1730 $_mat-theme-emitted-density, ($id: $previous-density)) !global;
1731 $_mat-theme-emitted-typography: map-merge(
1732 $_mat-theme-emitted-typography, ($id: $previous-typography)) !global;
1733
1734 // Optionally, consumers of this mixin can wrap contents inside so that nested
1735 // duplicate style checks do not report another warning. e.g. if developers include
1736 // the `angular-material-theme` mixin twice, only the top-level duplicate styles check
1737 // should report a warning. Not all individual components should report a warning too.
1738 $orig-mat-theme-ignore-duplication-warnings: $mat-theme-ignore-duplication-warnings;
1739 $mat-theme-ignore-duplication-warnings: true !global;
1740
1741 // If duplicate default density styles would be generated for a legacy constructed theme,
1742 // we adjust the density generation so that no density styles are generated by default.
1743 // If no default density styles have been generated yet, we ensure that the styles
1744 // are generated at root. For legacy themes our goal is to generate default density
1745 // styles **once** and at root. This matches the old behavior where density styles were
1746 // part of the base component styles (that did not use view encapsulation).
1747 // TODO: Remove this compatibility logic when the legacy theming API is removed.
1748 $mat-private-density-generate-at-root: mat-private-is-legacy-constructed-theme($theme) !global;
1749 $mat-private-density-generate-styles: not $duplicate-legacy-density !global;
1750
1751 @content;
1752 $mat-theme-ignore-duplication-warnings: $orig-mat-theme-ignore-duplication-warnings !global;
1753
1754 $mat-private-density-generate-at-root: false !global;
1755 $mat-private-density-generate-styles: true !global;
1756}
1757
1758// Checks whether the given value resolves to a theme object. Theme objects are always
1759// of type `map` and can optionally only specify `color`, `density` or `typography`.
1760@function mat-private-is-theme-object($value) {
1761 @return type-of($value) == 'map' and (
1762 map-has-key($value, color) or
1763 map-has-key($value, density) or
1764 map-has-key($value, typography) or
1765 length($value) == 0
1766 );
1767}
1768
1769// Checks whether a given value corresponds to a legacy constructed theme.
1770@function mat-private-is-legacy-constructed-theme($value) {
1771 @return type-of($value) == 'map' and map-get($value, '_is-legacy-theme');
1772}
1773
1774// Creates a backwards compatible theme. Previously in Angular Material, theme objects
1775// contained the color configuration directly. With the recent refactoring of the theming
1776// system to allow for density and typography configurations, this is no longer the case.
1777// To ensure that constructed themes which will be passed to custom theme mixins do not break,
1778// we copy the color configuration and put its properties at the top-level of the theme object.
1779// Here is an example of a pattern that should still work until it's officially marked as a
1780// breaking change:
1781//
1782// @mixin my-custom-component-theme($theme) {
1783// .my-comp {
1784// background-color: mat-color(map-get($theme, primary));
1785// }
1786// }
1787//
1788// Note that the `$theme.primary` key does usually not exist since the color configuration
1789// is stored in `$theme.color` which contains a property for `primary`. This method copies
1790// the map from `$theme.color` to `$theme` for backwards compatibility.
1791@function mat-private-create-backwards-compatibility-theme($theme) {
1792 @if not map-get($theme, color) {
1793 @return $theme;
1794 }
1795 $color: map-get($theme, color);
1796 @return map-merge($theme, $color);
1797}
1798
1799// Gets the theme from the given value that is either already a theme, or a color configuration.
1800// This handles the legacy case where developers pass a color configuration directly to the
1801// theme mixin. Before we introduced the new pattern for constructing a theme, developers passed
1802// the color configuration directly to the theme mixins. This can be still the case if developers
1803// construct a theme manually and pass it to a theme. We support this for backwards compatibility.
1804// TODO(devversion): remove this in the future. Constructing themes manually is rare,
1805// and the code can be easily updated to the new API.
1806@function mat-private-legacy-get-theme($theme-or-color-config) {
1807 @if mat-private-is-theme-object($theme-or-color-config) {
1808 @return $theme-or-color-config;
1809 }
1810 @return mat-private-create-backwards-compatibility-theme((
1811 _is-legacy-theme: true,
1812 color: $theme-or-color-config
1813 ));
1814}
1815
1816
1817
1818$mat-ripple-color-opacity: 0.1;
1819
1820@mixin mat-ripple() {
1821
1822 // The host element of an mat-ripple directive should always have a position of "absolute" or
1823 // "relative" so that the ripples inside are correctly positioned relatively to the container.
1824 .mat-ripple {
1825 overflow: hidden;
1826
1827 // By default, every ripple container should have position: relative in favor of creating an
1828 // easy API for developers using the MatRipple directive.
1829 position: relative;
1830
1831 // Promote containers that have ripples to a new layer. We want to target `:not(:empty)`,
1832 // because we don't want all ripple containers to have their own layer since they're used in a
1833 // lot of places and the layer is only relevant while animating. Note that ideally we'd use
1834 // the `contain` property here (see #13175), because `:empty` can be broken by having extra
1835 // text inside the element, but it isn't very well supported yet.
1836 &:not(:empty) {
1837 transform: translateZ(0);
1838 }
1839 }
1840
1841 .mat-ripple.mat-ripple-unbounded {
1842 overflow: visible;
1843 }
1844
1845 .mat-ripple-element {
1846 position: absolute;
1847 border-radius: 50%;
1848 pointer-events: none;
1849
1850 transition: opacity, transform 0ms cubic-bezier(0, 0, 0.2, 1);
1851 transform: scale(0);
1852
1853 // In high contrast mode the ripple is opaque, causing it to obstruct the content.
1854 @include cdk-high-contrast(active, off) {
1855 display: none;
1856 }
1857 }
1858}
1859
1860/* Colors for the ripple elements.*/
1861@mixin mat-ripple-color($config-or-theme) {
1862 $config: mat-get-color-config($config-or-theme);
1863 $foreground: map-get($config, foreground);
1864 $foreground-base: map-get($foreground, base);
1865
1866 .mat-ripple-element {
1867 // If the ripple color is resolves to a color *type*, we can use it directly, otherwise
1868 // (e.g. it resolves to a CSS variable) we fall back to using the color and setting an opacity.
1869 @if (type-of($foreground-base) == color) {
1870 background-color: rgba($foreground-base, $mat-ripple-color-opacity);
1871 }
1872 @else {
1873 background-color: $foreground-base;
1874 opacity: $mat-ripple-color-opacity;
1875 }
1876 }
1877}
1878
1879@mixin mat-ripple-theme($theme-or-color-config) {
1880 $theme: mat-private-legacy-get-theme($theme-or-color-config);
1881 @include mat-private-check-duplicate-theme-styles($theme, 'mat-ripple') {
1882 $color: mat-get-color-config($theme);
1883 @if $color != null {
1884 @include mat-ripple-color($color);
1885 }
1886 }
1887}
1888
1889
1890// This mixin ensures an element spans to fill the nearest ancestor with defined positioning.
1891@mixin mat-fill {
1892 top: 0;
1893 left: 0;
1894 right: 0;
1895 bottom: 0;
1896 position: absolute;
1897}
1898
1899
1900/// Mixin that turns on strong focus indicators.
1901///
1902/// @example
1903/// .my-app {
1904/// @include mat-strong-focus-indicators($config);
1905/// }
1906@mixin mat-strong-focus-indicators($config: ()) {
1907 // Default focus indicator config.
1908 $default-config: (
1909 border-style: solid,
1910 border-width: 3px,
1911 border-radius: 4px,
1912 );
1913
1914 // Merge default config with user config.
1915 $config: map-merge($default-config, $config);
1916 $border-style: map-get($config, border-style);
1917 $border-width: map-get($config, border-width);
1918 $border-radius: map-get($config, border-radius);
1919
1920 // Base styles for focus indicators.
1921 .mat-focus-indicator::before {
1922 @include mat-fill();
1923 box-sizing: border-box;
1924 pointer-events: none;
1925 border: $border-width $border-style transparent;
1926 border-radius: $border-radius;
1927 }
1928
1929 // By default, all focus indicators are flush with the bounding box of their
1930 // host element. For particular elements (listed below), default inset/offset
1931 // values are necessary to ensure that the focus indicator is sufficiently
1932 // contrastive and renders appropriately.
1933
1934 .mat-focus-indicator.mat-flat-button::before,
1935 .mat-focus-indicator.mat-raised-button::before,
1936 .mat-focus-indicator.mat-fab::before,
1937 .mat-focus-indicator.mat-mini-fab::before,
1938 .mat-focus-indicator.mat-chip::before,
1939 .mat-focus-indicator.mat-sort-header-container::before {
1940 margin: -($border-width + 2px);
1941 }
1942
1943 .mat-focus-indicator.mat-stroked-button::before,
1944 .mat-focus-indicator.mat-calendar-body-cell-content::before {
1945 margin: -($border-width + 3px);
1946 }
1947
1948 .mat-focus-indicator.mat-tab-link::before,
1949 .mat-focus-indicator.mat-tab-label::before {
1950 margin: 5px;
1951 }
1952
1953 // Render the focus indicator on focus. Defining a pseudo element's
1954 // content will cause it to render.
1955
1956 // Checkboxes, radios, and slide toggles render focus indicators when the
1957 // associated visually-hidden input is focused.
1958 .mat-checkbox-input:focus ~ .mat-focus-indicator::before,
1959 .mat-radio-input:focus ~ .mat-focus-indicator::before,
1960 .mat-slide-toggle-input:focus ~ .mat-slide-toggle-thumb-container .mat-focus-indicator::before,
1961
1962 // For options, render the focus indicator when the class .mat-active
1963 // is present.
1964 .mat-focus-indicator.mat-option.mat-active::before,
1965
1966 // For calendar cells, render the focus indicator when the parent cell is
1967 // focused.
1968 .mat-calendar-body-cell:focus .mat-focus-indicator::before,
1969
1970 // For all other components, render the focus indicator on focus.
1971 .mat-focus-indicator:focus::before {
1972 content: '';
1973 }
1974}
1975
1976// Mixin that applies the border color for the focus indicators.
1977@mixin _mat-strong-focus-indicators-border-color($color) {
1978 .mat-focus-indicator::before {
1979 border-color: $color;
1980 }
1981}
1982
1983@mixin mat-strong-focus-indicators-color($config-or-theme) {
1984 $config: mat-get-color-config($config-or-theme);
1985 @include _mat-strong-focus-indicators-border-color(mat-color(map-get($config, primary)));
1986}
1987
1988/// Mixin that sets the color of the focus indicators.
1989///
1990/// @param {color|map} $theme-or-color
1991/// If theme, focus indicators are set to the primary color of the theme. If
1992/// color, focus indicators are set to that color.
1993///
1994/// @example
1995/// .demo-dark-theme {
1996/// @include mat-strong-focus-indicators-theme($dark-theme-map);
1997/// }
1998///
1999/// @example
2000/// .demo-red-theme {
2001/// @include mat-strong-focus-indicators-theme(#f00);
2002/// }
2003/* stylelint-disable-next-line material/theme-mixin-api */
2004@mixin mat-strong-focus-indicators-theme($theme-or-color) {
2005 @if type-of($theme-or-color) != 'map' {
2006 @include _mat-strong-focus-indicators-border-color($theme-or-color);
2007 }
2008 @else {
2009 $theme: mat-private-legacy-get-theme($theme-or-color);
2010 @include mat-private-check-duplicate-theme-styles($theme, 'mat-strong-focus-indicators') {
2011 $color: mat-get-color-config($theme);
2012 @if $color != null {
2013 @include mat-strong-focus-indicators-color($color);
2014 }
2015 }
2016 }
2017}
2018
2019// Mixin that ensures focus indicator host elements are positioned so that the focus indicator
2020// pseudo element within is positioned relative to the host. Private mixin included within
2021// `mat-core`.
2022@mixin mat-private-strong-focus-indicators-positioning() {
2023 .mat-focus-indicator {
2024 position: relative;
2025 }
2026}
2027
2028
2029
2030// Utility for fetching a nested value from a typography config.
2031@function _mat-get-type-value($config, $level, $name) {
2032 @return map-get(map-get($config, $level), $name);
2033}
2034
2035// Gets the font size for a level inside a typography config.
2036@function mat-font-size($config, $level) {
2037 @return _mat-get-type-value($config, $level, font-size);
2038}
2039
2040// Gets the line height for a level inside a typography config.
2041@function mat-line-height($config, $level) {
2042 @return _mat-get-type-value($config, $level, line-height);
2043}
2044
2045// Gets the font weight for a level inside a typography config.
2046@function mat-font-weight($config, $level) {
2047 @return _mat-get-type-value($config, $level, font-weight);
2048}
2049
2050// Gets the letter spacing for a level inside a typography config.
2051@function mat-letter-spacing($config, $level) {
2052 @return _mat-get-type-value($config, $level, letter-spacing);
2053}
2054
2055// Gets the font-family from a typography config and removes the quotes around it.
2056@function mat-font-family($config, $level: null) {
2057 $font-family: map-get($config, font-family);
2058
2059 @if $level != null {
2060 $font-family: _mat-get-type-value($config, $level, font-family);
2061 }
2062
2063 // Guard against unquoting non-string values, because it's deprecated.
2064 @return if(type-of($font-family) == string, unquote($font-family), $font-family);
2065}
2066
2067// Outputs the shorthand `font` CSS property, based on a set of typography values. Falls back to
2068// the individual properties if a value that isn't allowed in the shorthand is passed in.
2069@mixin mat-typography-font-shorthand($font-size, $font-weight, $line-height, $font-family) {
2070 // If any of the values are set to `inherit`, we can't use the shorthand
2071 // so we fall back to passing in the individual properties.
2072 @if ($font-size == inherit or
2073 $font-weight == inherit or
2074 $line-height == inherit or
2075 $font-family == inherit or
2076 $font-size == null or
2077 $font-weight == null or
2078 $line-height == null or
2079 $font-family == null) {
2080
2081 font-size: $font-size;
2082 font-weight: $font-weight;
2083 line-height: $line-height;
2084 font-family: $font-family;
2085 }
2086 @else {
2087 // Otherwise use the shorthand `font`, because it's the least amount of bytes. Note
2088 // that we need to use interpolation for `font-size/line-height` in order to prevent
2089 // Sass from dividing the two values.
2090 font: $font-weight #{$font-size}/#{$line-height} $font-family;
2091 }
2092}
2093
2094// Converts a typography level into CSS styles.
2095@mixin mat-typography-level-to-styles($config, $level) {
2096 $font-size: mat-font-size($config, $level);
2097 $font-weight: mat-font-weight($config, $level);
2098 $line-height: mat-line-height($config, $level);
2099 $font-family: mat-font-family($config, $level);
2100
2101 @include mat-typography-font-shorthand($font-size, $font-weight, $line-height, $font-family);
2102 letter-spacing: mat-letter-spacing($config, $level);
2103}
2104
2105
2106@mixin mat-option-color($config-or-theme) {
2107 $config: mat-get-color-config($config-or-theme);
2108 $foreground: map-get($config, foreground);
2109 $background: map-get($config, background);
2110 $primary: map-get($config, primary);
2111 $accent: map-get($config, accent);
2112 $warn: map-get($config, warn);
2113
2114 .mat-option {
2115 color: mat-color($foreground, text);
2116
2117 &:hover:not(.mat-option-disabled),
2118 &:focus:not(.mat-option-disabled) {
2119 background: mat-color($background, hover);
2120 }
2121
2122 // In multiple mode there is a checkbox to show that the option is selected.
2123 &.mat-selected:not(.mat-option-multiple):not(.mat-option-disabled) {
2124 background: mat-color($background, hover);
2125 }
2126
2127 &.mat-active {
2128 background: mat-color($background, hover);
2129 color: mat-color($foreground, text);
2130 }
2131
2132 &.mat-option-disabled {
2133 color: mat-color($foreground, hint-text);
2134 }
2135 }
2136
2137 .mat-primary .mat-option.mat-selected:not(.mat-option-disabled) {
2138 color: mat-color($primary, text);
2139 }
2140
2141 .mat-accent .mat-option.mat-selected:not(.mat-option-disabled) {
2142 color: mat-color($accent, text);
2143 }
2144
2145 .mat-warn .mat-option.mat-selected:not(.mat-option-disabled) {
2146 color: mat-color($warn, text);
2147 }
2148}
2149
2150@mixin mat-option-typography($config-or-theme) {
2151 $config: mat-get-typography-config($config-or-theme);
2152 .mat-option {
2153 font: {
2154 family: mat-font-family($config);
2155 size: mat-font-size($config, subheading-2);
2156 }
2157 }
2158}
2159
2160@mixin _mat-option-density($config-or-theme) {}
2161
2162@mixin mat-option-theme($theme-or-color-config) {
2163 $theme: mat-private-legacy-get-theme($theme-or-color-config);
2164 @include mat-private-check-duplicate-theme-styles($theme, 'mat-option') {
2165 $color: mat-get-color-config($theme);
2166 $density: mat-get-density-config($theme);
2167 $typography: mat-get-typography-config($theme);
2168
2169 @if $color != null {
2170 @include mat-option-color($color);
2171 }
2172 @if $density != null {
2173 @include _mat-option-density($density);
2174 }
2175 @if $typography != null {
2176 @include mat-option-typography($typography);
2177 }
2178 }
2179}
2180
2181
2182
2183
2184
2185@mixin mat-optgroup-color($config-or-theme) {
2186 $config: mat-get-color-config($config-or-theme);
2187 $foreground: map-get($config, foreground);
2188
2189 .mat-optgroup-label {
2190 color: mat-color($foreground, secondary-text);
2191 }
2192
2193 .mat-optgroup-disabled .mat-optgroup-label {
2194 color: mat-color($foreground, hint-text);
2195 }
2196}
2197
2198@mixin mat-optgroup-typography($config-or-theme) {
2199 $config: mat-get-typography-config($config-or-theme);
2200 .mat-optgroup-label {
2201 @include mat-typography-level-to-styles($config, body-2);
2202 }
2203}
2204
2205@mixin _mat-optgroup-density($config-or-theme) {}
2206
2207@mixin mat-optgroup-theme($theme-or-color-config) {
2208 $theme: mat-private-legacy-get-theme($theme-or-color-config);
2209 @include mat-private-check-duplicate-theme-styles($theme, 'mat-optgroup') {
2210 $color: mat-get-color-config($theme);
2211 $density: mat-get-density-config($theme);
2212 $typography: mat-get-typography-config($theme);
2213
2214 @if $color != null {
2215 @include mat-optgroup-color($color);
2216 }
2217 @if $density != null {
2218 @include _mat-optgroup-density($density);
2219 }
2220 @if $typography != null {
2221 @include mat-optgroup-typography($typography);
2222 }
2223 }
2224}
2225
2226
2227
2228@mixin mat-pseudo-checkbox-color($config-or-theme) {
2229 $config: mat-get-color-config($config-or-theme);
2230 $is-dark-theme: map-get($config, is-dark);
2231 $primary: map-get($config, primary);
2232 $accent: map-get($config, accent);
2233 $warn: map-get($config, warn);
2234 $background: map-get($config, background);
2235
2236 // NOTE(traviskaufman): While the spec calls for translucent blacks/whites for disabled colors,
2237 // this does not work well with elements layered on top of one another. To get around this we
2238 // blend the colors together based on the base color and the theme background.
2239 $white-30pct-opacity-on-dark: #686868;
2240 $black-26pct-opacity-on-light: #b0b0b0;
2241 $disabled-color: if($is-dark-theme, $white-30pct-opacity-on-dark, $black-26pct-opacity-on-light);
2242 $colored-box-selector: '.mat-pseudo-checkbox-checked, .mat-pseudo-checkbox-indeterminate';
2243
2244 .mat-pseudo-checkbox {
2245 color: mat-color(map-get($config, foreground), secondary-text);
2246
2247 &::after {
2248 color: mat-color($background, background);
2249 }
2250 }
2251
2252 .mat-pseudo-checkbox-disabled {
2253 color: $disabled-color;
2254 }
2255
2256 .mat-primary .mat-pseudo-checkbox-checked,
2257 .mat-primary .mat-pseudo-checkbox-indeterminate {
2258 background: mat-color(map-get($config, primary));
2259 }
2260
2261 // Default to the accent color. Note that the pseudo checkboxes are meant to inherit the
2262 // theme from their parent, rather than implementing their own theming, which is why we
2263 // don't attach to the `mat-*` classes. Also note that this needs to be below `.mat-primary`
2264 // in order to allow for the color to be overwritten if the checkbox is inside a parent that
2265 // has `mat-accent` and is placed inside another parent that has `mat-primary`.
2266 .mat-pseudo-checkbox-checked,
2267 .mat-pseudo-checkbox-indeterminate,
2268 .mat-accent .mat-pseudo-checkbox-checked,
2269 .mat-accent .mat-pseudo-checkbox-indeterminate {
2270 background: mat-color(map-get($config, accent));
2271 }
2272
2273 .mat-warn .mat-pseudo-checkbox-checked,
2274 .mat-warn .mat-pseudo-checkbox-indeterminate {
2275 background: mat-color(map-get($config, warn));
2276 }
2277
2278 .mat-pseudo-checkbox-checked,
2279 .mat-pseudo-checkbox-indeterminate {
2280 &.mat-pseudo-checkbox-disabled {
2281 background: $disabled-color;
2282 }
2283 }
2284}
2285
2286@mixin mat-pseudo-checkbox-typography($config-or-theme) {}
2287
2288@mixin _mat-pseudo-checkbox-density($config-or-theme) {}
2289
2290@mixin mat-pseudo-checkbox-theme($theme-or-color-config) {
2291 $theme: mat-private-legacy-get-theme($theme-or-color-config);
2292 @include mat-private-check-duplicate-theme-styles($theme, 'mat-pseudo-checkbox') {
2293 $color: mat-get-color-config($theme);
2294 $density: mat-get-density-config($theme);
2295 $typography: mat-get-typography-config($theme);
2296
2297 @if $color != null {
2298 @include mat-pseudo-checkbox-color($color);
2299 }
2300 @if $density != null {
2301 @include _mat-pseudo-checkbox-density($density);
2302 }
2303 @if $typography != null {
2304 @include mat-pseudo-checkbox-typography($typography);
2305 }
2306 }
2307}
2308
2309
2310
2311// Represents a typography level from the Material design spec.
2312@function mat-typography-level(
2313 $font-size,
2314 $line-height: $font-size,
2315 $font-weight: 400,
2316 $font-family: null,
2317 $letter-spacing: normal) {
2318
2319 @return (
2320 font-size: $font-size,
2321 line-height: $line-height,
2322 font-weight: $font-weight,
2323 font-family: $font-family,
2324 letter-spacing: $letter-spacing
2325 );
2326}
2327
2328// Represents a collection of typography levels.
2329// Defaults come from https://material.io/guidelines/style/typography.html
2330// Note: The spec doesn't mention letter spacing. The values here come from
2331// eyeballing it until it looked exactly like the spec examples.
2332@function mat-typography-config(
2333 $font-family: 'Roboto, "Helvetica Neue", sans-serif',
2334 $display-4: mat-typography-level(112px, 112px, 300, $letter-spacing: -0.05em),
2335 $display-3: mat-typography-level(56px, 56px, 400, $letter-spacing: -0.02em),
2336 $display-2: mat-typography-level(45px, 48px, 400, $letter-spacing: -0.005em),
2337 $display-1: mat-typography-level(34px, 40px, 400),
2338 $headline: mat-typography-level(24px, 32px, 400),
2339 $title: mat-typography-level(20px, 32px, 500),
2340 $subheading-2: mat-typography-level(16px, 28px, 400),
2341 $subheading-1: mat-typography-level(15px, 24px, 400),
2342 $body-2: mat-typography-level(14px, 24px, 500),
2343 $body-1: mat-typography-level(14px, 20px, 400),
2344 $caption: mat-typography-level(12px, 20px, 400),
2345 $button: mat-typography-level(14px, 14px, 500),
2346 // Line-height must be unit-less fraction of the font-size.
2347 $input: mat-typography-level(inherit, 1.125, 400)
2348) {
2349
2350 // Declare an initial map with all of the levels.
2351 $config: (
2352 display-4: $display-4,
2353 display-3: $display-3,
2354 display-2: $display-2,
2355 display-1: $display-1,
2356 headline: $headline,
2357 title: $title,
2358 subheading-2: $subheading-2,
2359 subheading-1: $subheading-1,
2360 body-2: $body-2,
2361 body-1: $body-1,
2362 caption: $caption,
2363 button: $button,
2364 input: $input,
2365 );
2366
2367 // Loop through the levels and set the `font-family` of the ones that don't have one to the base.
2368 // Note that Sass can't modify maps in place, which means that we need to merge and re-assign.
2369 @each $key, $level in $config {
2370 @if map-get($level, font-family) == null {
2371 $new-level: map-merge($level, (font-family: $font-family));
2372 $config: map-merge($config, ($key: $new-level));
2373 }
2374 }
2375
2376 // Add the base font family to the config.
2377 @return map-merge($config, (font-family: $font-family));
2378}
2379
2380// Whether a config is for the Material Design 2018 typography system.
2381@function mat-private-typography-is-2018-config($config) {
2382 @return map-get($config, headline-1) != null;
2383}
2384
2385// Whether a config is for the Material Design 2014 typography system.
2386@function mat-private-typography-is-2014-config($config) {
2387 @return map-get($config, headline) != null;
2388}
2389
2390// Given a config for either the 2014 or 2018 Material Design typography system,
2391// produces a normalized typography config for the 2014 Material Design typography system.
2392// 2014 - https://material.io/archive/guidelines/style/typography.html#typography-styles
2393// 2018 - https://material.io/design/typography/the-type-system.html#type-scale
2394@function mat-private-typography-to-2014-config($config) {
2395 @if mat-private-typography-is-2018-config($config) {
2396 @return mat-typography-config(
2397 $display-4: map-get($config, headline-1),
2398 $display-3: map-get($config, headline-2),
2399 $display-2: map-get($config, headline-3),
2400 $display-1: map-get($config, headline-4),
2401 $headline: map-get($config, headline-5),
2402 $title: map-get($config, headline-6),
2403 $subheading-2: map-get($config, subtitle-1),
2404 $subheading-1: map-get($config, subtitle-2),
2405 $body-2: map-get($config, body-1),
2406 $body-1: map-get($config, body-2),
2407 $button: map-get($config, button),
2408 $caption: map-get($config, caption),
2409 );
2410 }
2411 @return $config;
2412}
2413
2414// Given a config for either the 2014 or 2018 Material Design typography system,
2415// produces a normalized typography config for the 2018 Material Design typography system.
2416// 2014 - https://material.io/archive/guidelines/style/typography.html#typography-styles
2417// 2018 - https://material.io/design/typography/the-type-system.html#type-scale
2418@function mat-private-typography-to-2018-config($config) {
2419 @if mat-private-typography-is-2014-config($config) {
2420 @return (
2421 headline-1: map-get($config, display-4),
2422 headline-2: map-get($config, display-3),
2423 headline-3: map-get($config, display-2),
2424 headline-4: map-get($config, display-1),
2425 headline-5: map-get($config, headline),
2426 headline-6: map-get($config, title),
2427 subtitle-1: map-get($config, subheading-2),
2428 subtitle-2: map-get($config, subheading-1),
2429 body-1: map-get($config, body-2),
2430 body-2: map-get($config, body-1),
2431 button: map-get($config, button),
2432 caption: map-get($config, caption),
2433 );
2434 }
2435 @return $config;
2436}
2437
2438// Adds the base typography styles, based on a config.
2439/* stylelint-disable-next-line material/theme-mixin-api */
2440@mixin mat-base-typography($config, $selector: '.mat-typography') {
2441 .mat-h1, .mat-headline, #{$selector} h1 {
2442 @include mat-typography-level-to-styles($config, headline);
2443 margin: 0 0 16px;
2444 }
2445
2446 .mat-h2, .mat-title, #{$selector} h2 {
2447 @include mat-typography-level-to-styles($config, title);
2448 margin: 0 0 16px;
2449 }
2450
2451 .mat-h3, .mat-subheading-2, #{$selector} h3 {
2452 @include mat-typography-level-to-styles($config, subheading-2);
2453 margin: 0 0 16px;
2454 }
2455
2456 .mat-h4, .mat-subheading-1, #{$selector} h4 {
2457 @include mat-typography-level-to-styles($config, subheading-1);
2458 margin: 0 0 16px;
2459 }
2460
2461 // Note: the spec doesn't have anything that would correspond to h5 and h6, but we add these for
2462 // consistency. The font sizes come from the Chrome user agent styles which have h5 at 0.83em
2463 // and h6 at 0.67em.
2464 .mat-h5, #{$selector} h5 {
2465 @include mat-typography-font-shorthand(
2466 // calc is used here to support css variables
2467 calc(#{mat-font-size($config, body-1)} * 0.83),
2468 mat-font-weight($config, body-1),
2469 mat-line-height($config, body-1),
2470 mat-font-family($config, body-1)
2471 );
2472
2473 margin: 0 0 12px;
2474 }
2475
2476 .mat-h6, #{$selector} h6 {
2477 @include mat-typography-font-shorthand(
2478 // calc is used here to support css variables
2479 calc(#{mat-font-size($config, body-1)} * 0.67),
2480 mat-font-weight($config, body-1),
2481 mat-line-height($config, body-1),
2482 mat-font-family($config, body-1)
2483 );
2484
2485 margin: 0 0 12px;
2486 }
2487
2488 .mat-body-strong, .mat-body-2 {
2489 @include mat-typography-level-to-styles($config, body-2);
2490 }
2491
2492 .mat-body, .mat-body-1, #{$selector} {
2493 @include mat-typography-level-to-styles($config, body-1);
2494
2495 p {
2496 margin: 0 0 12px;
2497 }
2498 }
2499
2500 .mat-small, .mat-caption {
2501 @include mat-typography-level-to-styles($config, caption);
2502 }
2503
2504 .mat-display-4, #{$selector} .mat-display-4 {
2505 @include mat-typography-level-to-styles($config, display-4);
2506 margin: 0 0 56px;
2507 }
2508
2509 .mat-display-3, #{$selector} .mat-display-3 {
2510 @include mat-typography-level-to-styles($config, display-3);
2511 margin: 0 0 64px;
2512 }
2513
2514 .mat-display-2, #{$selector} .mat-display-2 {
2515 @include mat-typography-level-to-styles($config, display-2);
2516 margin: 0 0 64px;
2517 }
2518
2519 .mat-display-1, #{$selector} .mat-display-1 {
2520 @include mat-typography-level-to-styles($config, display-1);
2521 margin: 0 0 64px;
2522 }
2523}
2524
2525
2526
2527
2528@mixin mat-autocomplete-color($config-or-theme) {
2529 $config: mat-get-color-config($config-or-theme);
2530 $foreground: map-get($config, foreground);
2531 $background: map-get($config, background);
2532
2533 .mat-autocomplete-panel {
2534 @include mat-private-theme-overridable-elevation(4, $config);
2535 background: mat-color($background, card);
2536 color: mat-color($foreground, text);
2537
2538 // Selected options in autocompletes should not be gray, but we
2539 // only want to override the background for selected options if
2540 // they are *not* in hover or focus state. This change has to be
2541 // made here because base option styles are shared between the
2542 // autocomplete and the select.
2543 .mat-option.mat-selected:not(.mat-active):not(:hover) {
2544 background: mat-color($background, card);
2545
2546 &:not(.mat-option-disabled) {
2547 color: mat-color($foreground, text);
2548 }
2549 }
2550 }
2551}
2552
2553@mixin mat-autocomplete-typography($config-or-theme) {}
2554
2555@mixin _mat-autocomplete-density($config-or-theme) {}
2556
2557@mixin mat-autocomplete-theme($theme-or-color-config) {
2558 $theme: mat-private-legacy-get-theme($theme-or-color-config);
2559 @include mat-private-check-duplicate-theme-styles($theme, 'mat-autocomplete') {
2560 $color: mat-get-color-config($theme);
2561 $density: mat-get-density-config($theme);
2562 $typography: mat-get-typography-config($theme);
2563
2564 @if $color != null {
2565 @include mat-autocomplete-color($color);
2566 }
2567 @if $density != null {
2568 @include _mat-autocomplete-density($density);
2569 }
2570 @if $typography != null {
2571 @include mat-autocomplete-typography($typography);
2572 }
2573 }
2574}
2575
2576// This contains all of the styles for the badge
2577// rather than just the color/theme because of
2578// no style sheet support for directives.
2579
2580
2581
2582
2583
2584$mat-badge-font-size: 12px;
2585$mat-badge-font-weight: 600;
2586$mat-badge-default-size: 22px !default;
2587$mat-badge-small-size: $mat-badge-default-size - 6;
2588$mat-badge-large-size: $mat-badge-default-size + 6;
2589
2590// Mixin for building offset given different sizes
2591@mixin _mat-badge-size($size) {
2592 .mat-badge-content {
2593 width: $size;
2594 height: $size;
2595 line-height: $size;
2596 }
2597
2598 &.mat-badge-above {
2599 .mat-badge-content {
2600 top: -$size / 2;
2601 }
2602 }
2603
2604 &.mat-badge-below {
2605 .mat-badge-content {
2606 bottom: -$size / 2;
2607 }
2608 }
2609
2610 &.mat-badge-before {
2611 .mat-badge-content {
2612 left: -$size;
2613 }
2614 }
2615
2616 [dir='rtl'] &.mat-badge-before {
2617 .mat-badge-content {
2618 left: auto;
2619 right: -$size;
2620 }
2621 }
2622
2623 &.mat-badge-after {
2624 .mat-badge-content {
2625 right: -$size;
2626 }
2627 }
2628
2629 [dir='rtl'] &.mat-badge-after {
2630 .mat-badge-content {
2631 right: auto;
2632 left: -$size;
2633 }
2634 }
2635
2636 &.mat-badge-overlap {
2637 &.mat-badge-before {
2638 .mat-badge-content {
2639 left: -$size / 2;
2640 }
2641 }
2642
2643 [dir='rtl'] &.mat-badge-before {
2644 .mat-badge-content {
2645 left: auto;
2646 right: -$size / 2;
2647 }
2648 }
2649
2650 &.mat-badge-after {
2651 .mat-badge-content {
2652 right: -$size / 2;
2653 }
2654 }
2655
2656 [dir='rtl'] &.mat-badge-after {
2657 .mat-badge-content {
2658 right: auto;
2659 left: -$size / 2;
2660 }
2661 }
2662 }
2663}
2664
2665@mixin mat-badge-color($config-or-theme) {
2666 $config: mat-get-color-config($config-or-theme);
2667 $accent: map-get($config, accent);
2668 $warn: map-get($config, warn);
2669 $primary: map-get($config, primary);
2670 $background: map-get($config, background);
2671 $foreground: map-get($config, foreground);
2672
2673 .mat-badge-content {
2674 color: mat-color($primary, default-contrast);
2675 background: mat-color($primary);
2676
2677 @include cdk-high-contrast(active, off) {
2678 outline: solid 1px;
2679 border-radius: 0;
2680 }
2681 }
2682
2683 .mat-badge-accent {
2684 .mat-badge-content {
2685 background: mat-color($accent);
2686 color: mat-color($accent, default-contrast);
2687 }
2688 }
2689
2690 .mat-badge-warn {
2691 .mat-badge-content {
2692 color: mat-color($warn, default-contrast);
2693 background: mat-color($warn);
2694 }
2695 }
2696
2697 .mat-badge {
2698 position: relative;
2699 }
2700
2701 .mat-badge-hidden {
2702 .mat-badge-content {
2703 display: none;
2704 }
2705 }
2706
2707 .mat-badge-disabled {
2708 .mat-badge-content {
2709 $app-background: mat-color($background, 'background');
2710 $badge-color: mat-color($foreground, disabled-button);
2711
2712 // The disabled color usually has some kind of opacity, but because the badge is overlayed
2713 // on top of something else, it won't look good if it's opaque. If it is a color *type*,
2714 // we convert it into a solid color by taking the opacity from the rgba value and using
2715 // the value to determine the percentage of the background to put into foreground when
2716 // mixing the colors together.
2717 @if (type-of($badge-color) == color and type-of($app-background) == color) {
2718 $badge-opacity: opacity($badge-color);
2719 background: mix($app-background, rgba($badge-color, 1), (1 - $badge-opacity) * 100%);
2720 }
2721 @else {
2722 background: $badge-color;
2723 }
2724
2725 color: mat-color($foreground, disabled-text);
2726 }
2727 }
2728
2729 .mat-badge-content {
2730 position: absolute;
2731 text-align: center;
2732 display: inline-block;
2733 border-radius: 50%;
2734 transition: transform 200ms ease-in-out;
2735 transform: scale(0.6);
2736 overflow: hidden;
2737 white-space: nowrap;
2738 text-overflow: ellipsis;
2739 pointer-events: none;
2740 }
2741
2742 .ng-animate-disabled .mat-badge-content,
2743 .mat-badge-content._mat-animation-noopable {
2744 transition: none;
2745 }
2746
2747 // The active class is added after the element is added
2748 // so it can animate scale to default
2749 .mat-badge-content.mat-badge-active {
2750 // Scale to `none` instead of `1` to avoid blurry text in some browsers.
2751 transform: none;
2752 }
2753
2754 .mat-badge-small {
2755 @include _mat-badge-size($mat-badge-small-size);
2756 }
2757 .mat-badge-medium {
2758 @include _mat-badge-size($mat-badge-default-size);
2759 }
2760 .mat-badge-large {
2761 @include _mat-badge-size($mat-badge-large-size);
2762 }
2763}
2764
2765@mixin mat-badge-typography($config-or-theme) {
2766 $config: mat-get-typography-config($config-or-theme);
2767 .mat-badge-content {
2768 font-weight: $mat-badge-font-weight;
2769 font-size: $mat-badge-font-size;
2770 font-family: mat-font-family($config);
2771 }
2772
2773 .mat-badge-small .mat-badge-content {
2774 // Set the font size to 75% of the original.
2775 font-size: $mat-badge-font-size * 0.75;
2776 }
2777
2778 .mat-badge-large .mat-badge-content {
2779 font-size: $mat-badge-font-size * 2;
2780 }
2781}
2782
2783@mixin _mat-badge-density($config-or-theme) {}
2784
2785@mixin mat-badge-theme($theme-or-color-config) {
2786 $theme: mat-private-legacy-get-theme($theme-or-color-config);
2787 @include mat-private-check-duplicate-theme-styles($theme, 'mat-badge') {
2788 $color: mat-get-color-config($theme);
2789 $density: mat-get-density-config($theme);
2790 $typography: mat-get-typography-config($theme);
2791
2792 @if $color != null {
2793 @include mat-badge-color($color);
2794 }
2795 @if $density != null {
2796 @include _mat-badge-density($density);
2797 }
2798 @if $typography != null {
2799 @include mat-badge-typography($typography);
2800 }
2801 }
2802}
2803
2804
2805
2806
2807
2808
2809@mixin mat-bottom-sheet-color($config-or-theme) {
2810 $config: mat-get-color-config($config-or-theme);
2811 $background: map-get($config, background);
2812 $foreground: map-get($config, foreground);
2813
2814 .mat-bottom-sheet-container {
2815 @include mat-private-theme-elevation(16, $config);
2816 background: mat-color($background, dialog);
2817 color: mat-color($foreground, text);
2818 }
2819}
2820
2821@mixin mat-bottom-sheet-typography($config-or-theme) {
2822 $config: mat-get-typography-config($config-or-theme);
2823 .mat-bottom-sheet-container {
2824 @include mat-typography-level-to-styles($config, body-1);
2825 }
2826}
2827
2828@mixin _mat-bottom-sheet-density($config-or-theme) {}
2829
2830@mixin mat-bottom-sheet-theme($theme-or-color-config) {
2831 $theme: mat-private-legacy-get-theme($theme-or-color-config);
2832 @include mat-private-check-duplicate-theme-styles($theme, 'mat-bottom-sheet') {
2833 $color: mat-get-color-config($theme);
2834 $density: mat-get-density-config($theme);
2835 $typography: mat-get-typography-config($theme);
2836
2837 @if $color != null {
2838 @include mat-bottom-sheet-color($color);
2839 }
2840 @if $density != null {
2841 @include _mat-bottom-sheet-density($density);
2842 }
2843 @if $typography != null {
2844 @include mat-bottom-sheet-typography($typography);
2845 }
2846 }
2847}
2848
2849
2850
2851
2852
2853$_mat-button-ripple-opacity: 0.1;
2854
2855// Applies a focus style to an mat-button element for each of the supported palettes.
2856@mixin _mat-button-focus-overlay-color($config-or-theme) {
2857 $config: mat-get-color-config($config-or-theme);
2858 $primary: map-get($config, primary);
2859 $accent: map-get($config, accent);
2860 $warn: map-get($config, warn);
2861
2862 &.mat-primary .mat-button-focus-overlay {
2863 background-color: mat-color($primary);
2864 }
2865
2866 &.mat-accent .mat-button-focus-overlay {
2867 background-color: mat-color($accent);
2868 }
2869
2870 &.mat-warn .mat-button-focus-overlay {
2871 background-color: mat-color($warn);
2872 }
2873
2874 &.mat-button-disabled .mat-button-focus-overlay {
2875 background-color: transparent;
2876 }
2877}
2878
2879// Applies the background color for a ripple. If the value provided is not a Sass color,
2880// we assume that we've been given a CSS variable. Since we can't perform alpha-blending
2881// on a CSS variable, we instead add the opacity directly to the ripple element.
2882@mixin _mat-button-ripple-background($palette, $hue, $opacity) {
2883 $background-color: mat-color($palette, $hue, $opacity);
2884 background-color: $background-color;
2885 @if (type-of($background-color) != color) {
2886 opacity: $opacity;
2887 }
2888}
2889
2890@mixin _mat-button-ripple-color($theme, $hue, $opacity: $_mat-button-ripple-opacity) {
2891 $primary: map-get($theme, primary);
2892 $accent: map-get($theme, accent);
2893 $warn: map-get($theme, warn);
2894
2895 &.mat-primary .mat-ripple-element {
2896 @include _mat-button-ripple-background($primary, $hue, $opacity);
2897 }
2898
2899 &.mat-accent .mat-ripple-element {
2900 @include _mat-button-ripple-background($accent, $hue, $opacity);
2901 }
2902
2903 &.mat-warn .mat-ripple-element {
2904 @include _mat-button-ripple-background($warn, $hue, $opacity);
2905 }
2906}
2907
2908// Applies a property to an mat-button element for each of the supported palettes.
2909@mixin _mat-button-theme-property($theme, $property, $hue) {
2910 $primary: map-get($theme, primary);
2911 $accent: map-get($theme, accent);
2912 $warn: map-get($theme, warn);
2913 $background: map-get($theme, background);
2914 $foreground: map-get($theme, foreground);
2915
2916 &.mat-primary {
2917 #{$property}: mat-color($primary, $hue);
2918 }
2919 &.mat-accent {
2920 #{$property}: mat-color($accent, $hue);
2921 }
2922 &.mat-warn {
2923 #{$property}: mat-color($warn, $hue);
2924 }
2925
2926 &.mat-primary, &.mat-accent, &.mat-warn, &.mat-button-disabled {
2927 &.mat-button-disabled {
2928 $palette: if($property == 'color', $foreground, $background);
2929 #{$property}: mat-color($palette, disabled-button);
2930 }
2931 }
2932}
2933
2934@mixin mat-button-color($config-or-theme) {
2935 $config: mat-get-color-config($config-or-theme);
2936 $primary: map-get($config, primary);
2937 $accent: map-get($config, accent);
2938 $warn: map-get($config, warn);
2939 $background: map-get($config, background);
2940 $foreground: map-get($config, foreground);
2941
2942 .mat-button, .mat-icon-button, .mat-stroked-button {
2943 // Buttons without a background color should inherit the font color. This is necessary to
2944 // ensure that the button is readable on custom background colors. It's wrong to always assume
2945 // that those buttons are always placed inside of containers with the default background
2946 // color of the theme (e.g. themed toolbars).
2947 color: inherit;
2948 background: transparent;
2949
2950 @include _mat-button-theme-property($config, 'color', text);
2951 @include _mat-button-focus-overlay-color($config);
2952
2953 // Setup the ripple color to be based on the text color. This ensures that the ripples
2954 // are matching with the current theme palette and are in contrast to the background color
2955 // (e.g in themed toolbars).
2956 .mat-ripple-element {
2957 opacity: $_mat-button-ripple-opacity;
2958 background-color: currentColor;
2959 }
2960 }
2961
2962 .mat-button-focus-overlay {
2963 background: map-get($foreground, base);
2964 }
2965
2966 // Note: this needs a bit extra specificity, because we're not guaranteed the inclusion
2967 // order of the theme styles and the button reset may end up resetting this as well.
2968 .mat-stroked-button:not(.mat-button-disabled) {
2969 border-color: mat-color($foreground, divider);
2970 }
2971
2972 .mat-flat-button, .mat-raised-button, .mat-fab, .mat-mini-fab {
2973 // Default font and background color when not using any color palette.
2974 color: mat-color($foreground, text);
2975 background-color: mat-color($background, raised-button);
2976
2977 @include _mat-button-theme-property($config, 'color', default-contrast);
2978 @include _mat-button-theme-property($config, 'background-color', default);
2979 @include _mat-button-ripple-color($config, default-contrast);
2980 }
2981
2982 .mat-stroked-button, .mat-flat-button {
2983 @include mat-private-theme-overridable-elevation(0, $config);
2984 }
2985
2986 .mat-raised-button {
2987 @include mat-private-theme-overridable-elevation(2, $config);
2988
2989 &:not(.mat-button-disabled):active {
2990 @include mat-private-theme-overridable-elevation(8, $config);
2991 }
2992
2993 &.mat-button-disabled {
2994 @include mat-private-theme-overridable-elevation(0, $config);
2995 }
2996 }
2997
2998 .mat-fab, .mat-mini-fab {
2999 @include mat-private-theme-overridable-elevation(6, $config);
3000
3001 &:not(.mat-button-disabled):active {
3002 @include mat-private-theme-overridable-elevation(12, $config);
3003 }
3004
3005 &.mat-button-disabled {
3006 @include mat-private-theme-overridable-elevation(0, $config);
3007 }
3008 }
3009}
3010
3011@mixin mat-button-typography($config-or-theme) {
3012 $config: mat-get-typography-config($config-or-theme);
3013 .mat-button, .mat-raised-button, .mat-icon-button, .mat-stroked-button,
3014 .mat-flat-button, .mat-fab, .mat-mini-fab {
3015 font: {
3016 family: mat-font-family($config, button);
3017 size: mat-font-size($config, button);
3018 weight: mat-font-weight($config, button);
3019 }
3020 }
3021}
3022
3023@mixin _mat-button-density($config-or-theme) {}
3024
3025@mixin mat-button-theme($theme-or-color-config) {
3026 $theme: mat-private-legacy-get-theme($theme-or-color-config);
3027 @include mat-private-check-duplicate-theme-styles($theme, 'mat-button') {
3028 $color: mat-get-color-config($theme);
3029 $density: mat-get-density-config($theme);
3030 $typography: mat-get-typography-config($theme);
3031
3032 @if $color != null {
3033 @include mat-button-color($color);
3034 }
3035 @if $density != null {
3036 @include _mat-button-density($density);
3037 }
3038 @if $typography != null {
3039 @include mat-button-typography($typography);
3040 }
3041 }
3042}
3043
3044
3045
3046
3047
3048
3049
3050$mat-button-toggle-standard-height: 48px !default;
3051// Minimum height for highest density can vary based on the content that developers
3052// project into button-toggle's. We use a minimum of `24px` though because commonly
3053// icons or text are displayed. Icons by default have a size of `24px`.
3054$mat-button-toggle-standard-minimum-height: 24px !default;
3055$mat-button-toggle-standard-maximum-height: $mat-button-toggle-standard-height !default;
3056
3057$mat-button-toggle-standard-density-config: (
3058 height: (
3059 default: $mat-button-toggle-standard-height,
3060 maximum: $mat-button-toggle-standard-maximum-height,
3061 minimum: $mat-button-toggle-standard-minimum-height,
3062 )
3063) !default;
3064
3065
3066@mixin mat-button-toggle-color($config-or-theme) {
3067 $config: mat-get-color-config($config-or-theme);
3068 $foreground: map-get($config, foreground);
3069 $background: map-get($config, background);
3070 $divider-color: mat-color($foreground, divider);
3071
3072 .mat-button-toggle-standalone,
3073 .mat-button-toggle-group {
3074 @include mat-private-theme-elevation(2, $config);
3075 }
3076
3077 .mat-button-toggle-standalone.mat-button-toggle-appearance-standard,
3078 .mat-button-toggle-group-appearance-standard {
3079 box-shadow: none;
3080 }
3081
3082 .mat-button-toggle {
3083 color: mat-color($foreground, hint-text);
3084
3085 .mat-button-toggle-focus-overlay {
3086 background-color: mat-color($background, focused-button);
3087 }
3088 }
3089
3090 .mat-button-toggle-appearance-standard {
3091 color: mat-color($foreground, text);
3092 background: mat-color($background, card);
3093
3094 .mat-button-toggle-focus-overlay {
3095 background-color: mat-color($background, focused-button, 1);
3096 }
3097 }
3098
3099 .mat-button-toggle-group-appearance-standard .mat-button-toggle + .mat-button-toggle {
3100 border-left: solid 1px $divider-color;
3101 }
3102
3103 [dir='rtl'] .mat-button-toggle-group-appearance-standard .mat-button-toggle + .mat-button-toggle {
3104 border-left: none;
3105 border-right: solid 1px $divider-color;
3106 }
3107
3108 .mat-button-toggle-group-appearance-standard.mat-button-toggle-vertical {
3109 .mat-button-toggle + .mat-button-toggle {
3110 border-left: none;
3111 border-right: none;
3112 border-top: solid 1px $divider-color;
3113 }
3114 }
3115
3116 .mat-button-toggle-checked {
3117 background-color: mat-color($background, selected-button);
3118 color: mat-color($foreground, secondary-text);
3119
3120 &.mat-button-toggle-appearance-standard {
3121 color: mat-color($foreground, text);
3122 }
3123 }
3124
3125 .mat-button-toggle-disabled {
3126 color: mat-color($foreground, disabled-button);
3127 background-color: mat-color($background, disabled-button-toggle);
3128
3129 &.mat-button-toggle-appearance-standard {
3130 background: mat-color($background, card);
3131 }
3132
3133 &.mat-button-toggle-checked {
3134 background-color: mat-color($background, selected-disabled-button);
3135 }
3136 }
3137
3138 .mat-button-toggle-standalone.mat-button-toggle-appearance-standard,
3139 .mat-button-toggle-group-appearance-standard {
3140 border: solid 1px $divider-color;
3141 }
3142}
3143
3144@mixin mat-button-toggle-typography($config-or-theme) {
3145 $config: mat-get-typography-config($config-or-theme);
3146 .mat-button-toggle {
3147 font-family: mat-font-family($config);
3148 }
3149}
3150
3151@mixin mat-button-toggle-density($config-or-theme) {
3152 $density-scale: mat-get-density-config($config-or-theme);
3153 $standard-height: mat-private-density-prop-value(
3154 $mat-button-toggle-standard-density-config, $density-scale, height);
3155
3156 @include mat-private-density-legacy-compatibility() {
3157 .mat-button-toggle-appearance-standard .mat-button-toggle-label-content {
3158 line-height: $standard-height;
3159 }
3160 }
3161}
3162
3163@mixin mat-button-toggle-theme($theme-or-color-config) {
3164 $theme: mat-private-legacy-get-theme($theme-or-color-config);
3165 @include mat-private-check-duplicate-theme-styles($theme, 'mat-button-toggle') {
3166 $color: mat-get-color-config($theme);
3167 $density: mat-get-density-config($theme);
3168 $typography: mat-get-typography-config($theme);
3169
3170 @if $color != null {
3171 @include mat-button-toggle-color($color);
3172 }
3173 @if $density != null {
3174 @include mat-button-toggle-density($density);
3175 }
3176 @if $typography != null {
3177 @include mat-button-toggle-typography($typography);
3178 }
3179 }
3180}
3181
3182
3183
3184
3185
3186
3187
3188@mixin mat-card-color($config-or-theme) {
3189 $config: mat-get-color-config($config-or-theme);
3190 $background: map-get($config, background);
3191 $foreground: map-get($config, foreground);
3192
3193 .mat-card {
3194 @include mat-private-theme-overridable-elevation(1, $config);
3195 background: mat-color($background, card);
3196 color: mat-color($foreground, text);
3197
3198 // Needs extra specificity to be able to override the elevation selectors.
3199 &.mat-card-flat {
3200 @include mat-private-theme-overridable-elevation(0, $config);
3201 }
3202 }
3203
3204 .mat-card-subtitle {
3205 color: mat-color($foreground, secondary-text);
3206 }
3207}
3208
3209@mixin mat-card-typography($config-or-theme) {
3210 $config: mat-get-typography-config($config-or-theme);
3211 .mat-card {
3212 font-family: mat-font-family($config);
3213 }
3214
3215 .mat-card-title {
3216 font: {
3217 size: mat-font-size($config, headline);
3218 weight: mat-font-weight($config, title);
3219 }
3220 }
3221
3222 .mat-card-header .mat-card-title {
3223 font-size: mat-font-size($config, title);
3224 }
3225
3226 .mat-card-subtitle,
3227 .mat-card-content {
3228 font-size: mat-font-size($config, body-1);
3229 }
3230}
3231
3232@mixin _mat-card-density($config-or-theme) {}
3233
3234@mixin mat-card-theme($theme-or-color-config) {
3235 $theme: mat-private-legacy-get-theme($theme-or-color-config);
3236 @include mat-private-check-duplicate-theme-styles($theme, 'mat-card') {
3237 $color: mat-get-color-config($theme);
3238 $density: mat-get-density-config($theme);
3239 $typography: mat-get-typography-config($theme);
3240
3241 @if $color != null {
3242 @include mat-card-color($color);
3243 }
3244 @if $density != null {
3245 @include _mat-card-density($density);
3246 }
3247 @if $typography != null {
3248 @include mat-card-typography($typography);
3249 }
3250 }
3251}
3252
3253
3254
3255
3256
3257@mixin mat-checkbox-color($config-or-theme) {
3258 $config: mat-get-color-config($config-or-theme);
3259 $is-dark-theme: map-get($config, is-dark);
3260 $primary: map-get($config, primary);
3261 $accent: map-get($config, accent);
3262 $warn: map-get($config, warn);
3263 $background: map-get($config, background);
3264 $foreground: map-get($config, foreground);
3265
3266
3267 // The color of the checkbox's checkmark / mixedmark.
3268 $checkbox-mark-color: mat-color($background, background);
3269
3270 // NOTE(traviskaufman): While the spec calls for translucent blacks/whites for disabled colors,
3271 // this does not work well with elements layered on top of one another. To get around this we
3272 // blend the colors together based on the base color and the theme background.
3273 $white-30pct-opacity-on-dark: #686868;
3274 $black-26pct-opacity-on-light: #b0b0b0;
3275 $disabled-color: if($is-dark-theme, $white-30pct-opacity-on-dark, $black-26pct-opacity-on-light);
3276
3277 .mat-checkbox-frame {
3278 border-color: mat-color($foreground, secondary-text);
3279 }
3280
3281 .mat-checkbox-checkmark {
3282 fill: $checkbox-mark-color;
3283 }
3284
3285 .mat-checkbox-checkmark-path {
3286 // !important is needed here because a stroke must be set as an
3287 // attribute on the SVG in order for line animation to work properly.
3288 stroke: $checkbox-mark-color !important;
3289 }
3290
3291 .mat-checkbox-mixedmark {
3292 background-color: $checkbox-mark-color;
3293 }
3294
3295 .mat-checkbox-indeterminate, .mat-checkbox-checked {
3296 &.mat-primary .mat-checkbox-background {
3297 background-color: mat-color($primary);
3298 }
3299
3300 &.mat-accent .mat-checkbox-background {
3301 background-color: mat-color($accent);
3302 }
3303
3304 &.mat-warn .mat-checkbox-background {
3305 background-color: mat-color($warn);
3306 }
3307 }
3308
3309 .mat-checkbox-disabled {
3310 &.mat-checkbox-checked,
3311 &.mat-checkbox-indeterminate {
3312 .mat-checkbox-background {
3313 background-color: $disabled-color;
3314 }
3315 }
3316
3317 &:not(.mat-checkbox-checked) {
3318 .mat-checkbox-frame {
3319 border-color: $disabled-color;
3320 }
3321 }
3322
3323 .mat-checkbox-label {
3324 color: mat-color($foreground, secondary-text);
3325 }
3326 }
3327
3328 // Switch this to a solid color since we're using `opacity`
3329 // to control how opaque the ripple should be.
3330 .mat-checkbox .mat-ripple-element {
3331 background-color: map-get(map-get($config, foreground), base);
3332 }
3333
3334 .mat-checkbox-checked:not(.mat-checkbox-disabled),
3335 .mat-checkbox:active:not(.mat-checkbox-disabled) {
3336 &.mat-primary .mat-ripple-element {
3337 background: mat-color($primary);
3338 }
3339
3340 &.mat-accent .mat-ripple-element {
3341 background: mat-color($accent);
3342 }
3343
3344 &.mat-warn .mat-ripple-element {
3345 background: mat-color($warn);
3346 }
3347 }
3348}
3349
3350@mixin mat-checkbox-typography($config-or-theme) {
3351 $config: mat-get-typography-config($config-or-theme);
3352 .mat-checkbox {
3353 font-family: mat-font-family($config);
3354 }
3355
3356 // TODO(kara): Remove this style when fixing vertical baseline
3357 .mat-checkbox-layout .mat-checkbox-label {
3358 line-height: mat-line-height($config, body-2);
3359 }
3360}
3361
3362@mixin _mat-checkbox-density($config-or-theme) {}
3363
3364@mixin mat-checkbox-theme($theme-or-color-config) {
3365 $theme: mat-private-legacy-get-theme($theme-or-color-config);
3366 @include mat-private-check-duplicate-theme-styles($theme, 'mat-checkbox') {
3367 $color: mat-get-color-config($theme);
3368 $density: mat-get-density-config($theme);
3369 $typography: mat-get-typography-config($theme);
3370
3371 @if $color != null {
3372 @include mat-checkbox-color($color);
3373 }
3374 @if $density != null {
3375 @include _mat-checkbox-density($density);
3376 }
3377 @if $typography != null {
3378 @include mat-checkbox-typography($typography);
3379 }
3380 }
3381}
3382
3383
3384
3385
3386
3387
3388$mat-chip-remove-font-size: 18px;
3389
3390@mixin _mat-chip-element-color($foreground, $background) {
3391 background-color: $background;
3392 color: $foreground;
3393
3394 .mat-chip-remove {
3395 color: $foreground;
3396 opacity: 0.4;
3397 }
3398}
3399
3400
3401// Applies the background color for a ripple element.
3402// If the color value provided is not a Sass color,
3403// we assume that we've been given a CSS variable.
3404// Since we can't perform alpha-blending on a CSS variable,
3405// we instead add the opacity directly to the ripple element.
3406@mixin _mat-chips-ripple-background($palette, $default-contrast, $opacity) {
3407 $background-color: mat-color($palette, $default-contrast, $opacity);
3408 background-color: $background-color;
3409 @if (type-of($background-color) != color) {
3410 opacity: $opacity;
3411 }
3412}
3413
3414@mixin _mat-chip-theme-color($palette) {
3415 @include _mat-chip-element-color(mat-color($palette, default-contrast), mat-color($palette));
3416
3417 .mat-ripple-element {
3418 @include _mat-chips-ripple-background($palette, default-contrast, 0.1);
3419 }
3420}
3421
3422@mixin mat-chips-color($config-or-theme) {
3423 $config: mat-get-color-config($config-or-theme);
3424 $is-dark-theme: map-get($config, is-dark);
3425 $primary: map-get($config, primary);
3426 $accent: map-get($config, accent);
3427 $warn: map-get($config, warn);
3428 $background: map-get($config, background);
3429 $foreground: map-get($config, foreground);
3430
3431 $unselected-background: mat-color($background, unselected-chip);
3432 $unselected-foreground: mat-color($foreground, text);
3433
3434 .mat-chip.mat-standard-chip {
3435 @include _mat-chip-element-color($unselected-foreground, $unselected-background);
3436
3437 &:not(.mat-chip-disabled) {
3438 &:active {
3439 @include mat-private-theme-elevation(3, $config);
3440 }
3441
3442 .mat-chip-remove:hover {
3443 opacity: 0.54;
3444 }
3445 }
3446
3447 &.mat-chip-disabled {
3448 opacity: 0.4;
3449 }
3450
3451 &::after {
3452 background: map-get($foreground, base);
3453 }
3454 }
3455
3456 .mat-chip.mat-standard-chip.mat-chip-selected {
3457 &.mat-primary {
3458 @include _mat-chip-theme-color($primary);
3459 }
3460
3461 &.mat-warn {
3462 @include _mat-chip-theme-color($warn);
3463 }
3464
3465 &.mat-accent {
3466 @include _mat-chip-theme-color($accent);
3467 }
3468 }
3469}
3470
3471@mixin mat-chips-typography($config-or-theme) {
3472 $config: mat-get-typography-config($config-or-theme);
3473 .mat-chip {
3474 font-size: mat-font-size($config, body-2);
3475 font-weight: mat-font-weight($config, body-2);
3476
3477 .mat-chip-trailing-icon.mat-icon,
3478 .mat-chip-remove.mat-icon {
3479 font-size: $mat-chip-remove-font-size;
3480 }
3481 }
3482}
3483
3484@mixin _mat-chips-density($config-or-theme) {}
3485
3486@mixin mat-chips-theme($theme-or-color-config) {
3487 $theme: mat-private-legacy-get-theme($theme-or-color-config);
3488 @include mat-private-check-duplicate-theme-styles($theme, 'mat-chips') {
3489 $color: mat-get-color-config($theme);
3490 $density: mat-get-density-config($theme);
3491 $typography: mat-get-typography-config($theme);
3492
3493 @if $color != null {
3494 @include mat-chips-color($color);
3495 }
3496 @if $density != null {
3497 @include _mat-chips-density($density);
3498 }
3499 @if $typography != null {
3500 @include mat-chips-typography($typography);
3501 }
3502 }
3503}
3504
3505
3506
3507
3508
3509
3510@mixin mat-divider-color($config-or-theme) {
3511 $config: mat-get-color-config($config-or-theme);
3512 $foreground: map-get($config, foreground);
3513
3514 .mat-divider {
3515 border-top-color: mat-color($foreground, divider);
3516 }
3517
3518 .mat-divider-vertical {
3519 border-right-color: mat-color($foreground, divider);
3520 }
3521}
3522
3523@mixin mat-divider-typography($config-or-theme) {}
3524
3525@mixin _mat-divider-density($config-or-theme) {}
3526
3527@mixin mat-divider-theme($theme-or-color-config) {
3528 $theme: mat-private-legacy-get-theme($theme-or-color-config);
3529 @include mat-private-check-duplicate-theme-styles($theme, 'mat-divider') {
3530 $color: mat-get-color-config($theme);
3531 $density: mat-get-density-config($theme);
3532 $typography: mat-get-typography-config($theme);
3533
3534 @if $color != null {
3535 @include mat-divider-color($color);
3536 }
3537 @if $density != null {
3538 @include _mat-divider-density($density);
3539 }
3540 @if $typography != null {
3541 @include mat-divider-typography($typography);
3542 }
3543 }
3544}
3545
3546
3547
3548
3549
3550@mixin mat-table-color($config-or-theme) {
3551 $config: mat-get-color-config($config-or-theme);
3552 $background: map-get($config, background);
3553 $foreground: map-get($config, foreground);
3554
3555 .mat-table {
3556 background: mat-color($background, 'card');
3557 }
3558
3559 .mat-table thead, .mat-table tbody, .mat-table tfoot,
3560 mat-header-row, mat-row, mat-footer-row,
3561 [mat-header-row], [mat-row], [mat-footer-row],
3562 .mat-table-sticky {
3563 background: inherit;
3564 }
3565
3566 mat-row, mat-header-row, mat-footer-row,
3567 th.mat-header-cell, td.mat-cell, td.mat-footer-cell {
3568 border-bottom-color: mat-color($foreground, divider);
3569 }
3570
3571 .mat-header-cell {
3572 color: mat-color($foreground, secondary-text);
3573 }
3574
3575 .mat-cell, .mat-footer-cell {
3576 color: mat-color($foreground, text);
3577 }
3578}
3579
3580@mixin mat-table-typography($config-or-theme) {
3581 $config: mat-get-typography-config($config-or-theme);
3582 .mat-table {
3583 font-family: mat-font-family($config);
3584 }
3585
3586 .mat-header-cell {
3587 font-size: mat-font-size($config, caption);
3588 font-weight: mat-font-weight($config, body-2);
3589 }
3590
3591 .mat-cell, .mat-footer-cell {
3592 font-size: mat-font-size($config, body-1);
3593 }
3594}
3595
3596@mixin _mat-table-density($config-or-theme) {}
3597
3598@mixin mat-table-theme($theme-or-color-config) {
3599 $theme: mat-private-legacy-get-theme($theme-or-color-config);
3600 @include mat-private-check-duplicate-theme-styles($theme, 'mat-table') {
3601 $color: mat-get-color-config($theme);
3602 $density: mat-get-density-config($theme);
3603 $typography: mat-get-typography-config($theme);
3604
3605 @if $color != null {
3606 @include mat-table-color($color);
3607 }
3608 @if $density != null {
3609 @include _mat-table-density($density);
3610 }
3611 @if $typography != null {
3612 @include mat-table-typography($typography);
3613 }
3614 }
3615}
3616
3617
3618
3619
3620
3621
3622
3623$mat-datepicker-selected-today-box-shadow-width: 1px;
3624$mat-datepicker-selected-fade-amount: 0.6;
3625$mat-datepicker-range-fade-amount: 0.2;
3626$mat-datepicker-today-fade-amount: 0.2;
3627$mat-calendar-body-font-size: 13px !default;
3628$mat-calendar-weekday-table-font-size: 11px !default;
3629
3630@mixin _mat-datepicker-color($palette) {
3631 @include mat-date-range-colors(
3632 mat-color($palette, default, $mat-datepicker-range-fade-amount));
3633
3634 .mat-calendar-body-selected {
3635 background-color: mat-color($palette);
3636 color: mat-color($palette, default-contrast);
3637 }
3638
3639 .mat-calendar-body-disabled > .mat-calendar-body-selected {
3640 $background: mat-color($palette);
3641
3642 @if (type-of($background) == color) {
3643 background-color: fade-out($background, $mat-datepicker-selected-fade-amount);
3644 }
3645 @else {
3646 // If we couldn't resolve to background to a color (e.g. it's a CSS variable),
3647 // fall back to fading the content out via `opacity`.
3648 opacity: $mat-datepicker-today-fade-amount;
3649 }
3650 }
3651
3652 .mat-calendar-body-today.mat-calendar-body-selected {
3653 box-shadow: inset 0 0 0 $mat-datepicker-selected-today-box-shadow-width
3654 mat-color($palette, default-contrast);
3655 }
3656
3657 .mat-calendar-body-cell:not(.mat-calendar-body-disabled):hover,
3658 .cdk-keyboard-focused .mat-calendar-body-active,
3659 .cdk-program-focused .mat-calendar-body-active {
3660 & > .mat-calendar-body-cell-content {
3661 @include _mat-datepicker-unselected-cell {
3662 background-color: mat-color($palette, 0.3);
3663 }
3664 }
3665 }
3666}
3667
3668// Utility mixin to target cells that aren't selected. Used to make selector easier to follow.
3669@mixin _mat-datepicker-unselected-cell {
3670 &:not(.mat-calendar-body-selected):not(.mat-calendar-body-comparison-identical) {
3671 @content;
3672 }
3673}
3674
3675@mixin mat-datepicker-color($config-or-theme) {
3676 $config: mat-get-color-config($config-or-theme);
3677 $foreground: map-get($config, foreground);
3678 $background: map-get($config, background);
3679 $disabled-color: mat-color($foreground, disabled-text);
3680
3681 .mat-calendar-arrow {
3682 border-top-color: mat-color($foreground, icon);
3683 }
3684
3685 // The prev/next buttons need a bit more specificity to
3686 // avoid being overwritten by the .mat-icon-button.
3687 .mat-datepicker-toggle,
3688 .mat-datepicker-content .mat-calendar-next-button,
3689 .mat-datepicker-content .mat-calendar-previous-button {
3690 color: mat-color($foreground, icon);
3691 }
3692
3693 .mat-calendar-table-header {
3694 color: mat-color($foreground, hint-text);
3695 }
3696
3697 .mat-calendar-table-header-divider::after {
3698 background: mat-color($foreground, divider);
3699 }
3700
3701 .mat-calendar-body-label {
3702 color: mat-color($foreground, secondary-text);
3703 }
3704
3705 .mat-calendar-body-cell-content,
3706 .mat-date-range-input-separator {
3707 color: mat-color($foreground, text);
3708 border-color: transparent;
3709 }
3710
3711 .mat-calendar-body-disabled > .mat-calendar-body-cell-content {
3712 @include _mat-datepicker-unselected-cell {
3713 color: $disabled-color;
3714 }
3715 }
3716
3717 .mat-form-field-disabled .mat-date-range-input-separator {
3718 color: $disabled-color;
3719 }
3720
3721 .mat-calendar-body-in-preview {
3722 $divider-color: mat-color($foreground, divider);
3723
3724 @if type-of($divider-color) == color {
3725 // The divider color is set under the assumption that it'll be used
3726 // for a solid border, but because we're using a dashed border for the
3727 // preview range, we need to bump its opacity to ensure that it's visible.
3728 color: rgba($divider-color, min(opacity($divider-color) * 2, 1));
3729 }
3730 @else {
3731 color: $divider-color;
3732 }
3733 }
3734
3735 .mat-calendar-body-today {
3736 @include _mat-datepicker-unselected-cell {
3737 // Note: though it's not text, the border is a hint about the fact that this is today's date,
3738 // so we use the hint color.
3739 border-color: mat-color($foreground, hint-text);
3740 }
3741 }
3742
3743 .mat-calendar-body-disabled > .mat-calendar-body-today {
3744 @include _mat-datepicker-unselected-cell {
3745 $color: mat-color($foreground, hint-text);
3746
3747 @if (type-of($color) == color) {
3748 border-color: fade-out($color, $mat-datepicker-today-fade-amount);
3749 }
3750 @else {
3751 // If the color didn't resolve to a color value, but something like a CSS variable, we can't
3752 // fade it out so we fall back to reducing the element opacity. Note that we don't use the
3753 // $mat-datepicker-today-fade-amount, because hint text usually has some opacity applied
3754 // to it already and we don't want them to stack on top of each other.
3755 opacity: 0.5;
3756 }
3757 }
3758 }
3759
3760 @include _mat-datepicker-color(map-get($config, primary));
3761
3762 .mat-datepicker-content {
3763 @include mat-private-theme-elevation(4, $config);
3764 background-color: mat-color($background, card);
3765 color: mat-color($foreground, text);
3766
3767 &.mat-accent {
3768 @include _mat-datepicker-color(map-get($config, accent));
3769 }
3770
3771 &.mat-warn {
3772 @include _mat-datepicker-color(map-get($config, warn));
3773 }
3774 }
3775
3776 .mat-datepicker-content-touch {
3777 @include mat-private-theme-elevation(0, $config);
3778 }
3779
3780 .mat-datepicker-toggle-active {
3781 color: mat-color(map-get($config, primary), text);
3782
3783 &.mat-accent {
3784 color: mat-color(map-get($config, accent), text);
3785 }
3786
3787 &.mat-warn {
3788 color: mat-color(map-get($config, warn), text);
3789 }
3790 }
3791
3792 .mat-date-range-input-inner[disabled] {
3793 color: mat-color($foreground, disabled-text);
3794 }
3795}
3796
3797@mixin mat-datepicker-typography($config-or-theme) {
3798 $config: mat-get-typography-config($config-or-theme);
3799 .mat-calendar {
3800 font-family: mat-font-family($config);
3801 }
3802
3803 .mat-calendar-body {
3804 font-size: $mat-calendar-body-font-size;
3805 }
3806
3807 .mat-calendar-body-label,
3808 .mat-calendar-period-button {
3809 font: {
3810 size: mat-font-size($config, button);
3811 weight: mat-font-weight($config, button);
3812 }
3813 }
3814
3815 .mat-calendar-table-header th {
3816 font: {
3817 size: $mat-calendar-weekday-table-font-size;
3818 weight: mat-font-weight($config, body-1);
3819 }
3820 }
3821}
3822
3823@mixin mat-date-range-colors(
3824 $range-color,
3825 $comparison-color: rgba(#f9ab00, $mat-datepicker-range-fade-amount),
3826 $overlap-color: #a8dab5,
3827 $overlap-selected-color: darken($overlap-color, 30%)) {
3828
3829 .mat-calendar-body-in-range::before {
3830 background: $range-color;
3831 }
3832
3833 .mat-calendar-body-comparison-identical,
3834 .mat-calendar-body-in-comparison-range::before {
3835 background: $comparison-color;
3836 }
3837
3838 .mat-calendar-body-comparison-bridge-start::before,
3839 [dir='rtl'] .mat-calendar-body-comparison-bridge-end::before {
3840 background: linear-gradient(to right, $range-color 50%, $comparison-color 50%);
3841 }
3842
3843 .mat-calendar-body-comparison-bridge-end::before,
3844 [dir='rtl'] .mat-calendar-body-comparison-bridge-start::before {
3845 background: linear-gradient(to left, $range-color 50%, $comparison-color 50%);
3846 }
3847
3848 .mat-calendar-body-in-range > .mat-calendar-body-comparison-identical,
3849 .mat-calendar-body-in-comparison-range.mat-calendar-body-in-range::after {
3850 background: $overlap-color;
3851 }
3852
3853 .mat-calendar-body-comparison-identical.mat-calendar-body-selected,
3854 .mat-calendar-body-in-comparison-range > .mat-calendar-body-selected {
3855 background: $overlap-selected-color;
3856 }
3857}
3858
3859@mixin _mat-datepicker-density($config-or-theme) {}
3860
3861@mixin mat-datepicker-theme($theme-or-color-config) {
3862 $theme: mat-private-legacy-get-theme($theme-or-color-config);
3863 @include mat-private-check-duplicate-theme-styles($theme, 'mat-datepicker') {
3864 $color: mat-get-color-config($theme);
3865 $density: mat-get-density-config($theme);
3866 $typography: mat-get-typography-config($theme);
3867
3868 @if $color != null {
3869 @include mat-datepicker-color($color);
3870 }
3871 @if $density != null {
3872 @include _mat-datepicker-density($density);
3873 }
3874 @if $typography != null {
3875 @include mat-datepicker-typography($typography);
3876 }
3877 }
3878}
3879
3880
3881
3882
3883
3884
3885
3886@mixin mat-dialog-color($config-or-theme) {
3887 $config: mat-get-color-config($config-or-theme);
3888 $background: map-get($config, background);
3889 $foreground: map-get($config, foreground);
3890
3891 .mat-dialog-container {
3892 @include mat-private-theme-elevation(24, $config);
3893 background: mat-color($background, dialog);
3894 color: mat-color($foreground, text);
3895 }
3896}
3897
3898@mixin mat-dialog-typography($config-or-theme) {
3899 $config: mat-get-typography-config($config-or-theme);
3900 .mat-dialog-title {
3901 @include mat-typography-level-to-styles($config, title);
3902 }
3903}
3904
3905@mixin _mat-dialog-density($config-or-theme) {}
3906
3907@mixin mat-dialog-theme($theme-or-color-config) {
3908 $theme: mat-private-legacy-get-theme($theme-or-color-config);
3909 @include mat-private-check-duplicate-theme-styles($theme, 'mat-dialog') {
3910 $color: mat-get-color-config($theme);
3911 $density: mat-get-density-config($theme);
3912 $typography: mat-get-typography-config($theme);
3913
3914 @if $color != null {
3915 @include mat-dialog-color($color);
3916 }
3917 @if $density != null {
3918 @include _mat-dialog-density($density);
3919 }
3920 @if $typography != null {
3921 @include mat-dialog-typography($typography);
3922 }
3923 }
3924}
3925
3926
3927
3928
3929
3930
3931// Default minimum and maximum height for collapsed panel headers.
3932$mat-expansion-panel-header-collapsed-height: 48px !default;
3933$mat-expansion-panel-header-collapsed-minimum-height: 36px !default;
3934$mat-expansion-panel-header-collapsed-maximum-height:
3935 $mat-expansion-panel-header-collapsed-height !default;
3936
3937// Default minimum and maximum height for expanded panel headers.
3938$mat-expansion-panel-header-expanded-height: 64px !default;
3939$mat-expansion-panel-header-expanded-minimum-height: 48px !default;
3940$mat-expansion-panel-header-expanded-maximum-height:
3941 $mat-expansion-panel-header-expanded-height !default;
3942
3943// Density configuration for the expansion panel. Captures the
3944// height for both expanded and collapsed panel headers.
3945$mat-expansion-panel-header-density-config: (
3946 collapsed-height: (
3947 default: $mat-expansion-panel-header-collapsed-height,
3948 maximum: $mat-expansion-panel-header-collapsed-maximum-height,
3949 minimum: $mat-expansion-panel-header-collapsed-minimum-height,
3950 ),
3951 expanded-height: (
3952 default: $mat-expansion-panel-header-expanded-height,
3953 maximum: $mat-expansion-panel-header-expanded-maximum-height,
3954 minimum: $mat-expansion-panel-header-expanded-minimum-height,
3955 )
3956) !default;
3957
3958// Note: Keep this in sync with the animation timing for the toggle indicator
3959// and body expansion. These are animated using Angular animations.
3960$mat-expansion-panel-header-transition: 225ms cubic-bezier(0.4, 0, 0.2, 1);
3961
3962@mixin mat-private-expansion-focus {
3963 .mat-expansion-panel {
3964 & .mat-expansion-panel-header.cdk-keyboard-focused,
3965 & .mat-expansion-panel-header.cdk-program-focused,
3966 &:not(.mat-expanded) .mat-expansion-panel-header:hover {
3967 &:not([aria-disabled='true']) {
3968 @content;
3969 }
3970 }
3971 }
3972}
3973
3974
3975@mixin mat-expansion-panel-color($config-or-theme) {
3976 $config: mat-get-color-config($config-or-theme);
3977 $background: map-get($config, background);
3978 $foreground: map-get($config, foreground);
3979
3980 .mat-expansion-panel {
3981 @include mat-private-theme-overridable-elevation(2, $config);
3982 background: mat-color($background, card);
3983 color: mat-color($foreground, text);
3984 }
3985
3986 .mat-action-row {
3987 border-top-color: mat-color($foreground, divider);
3988 }
3989
3990 @include mat-private-expansion-focus {
3991 background: mat-color($background, hover);
3992 }
3993
3994 // Disable the hover on touch devices since it can appear like it is stuck. We can't use
3995 // `@media (hover)` above, because the desktop support browser support isn't great.
3996 @media (hover: none) {
3997 .mat-expansion-panel:not(.mat-expanded):not([aria-disabled='true'])
3998 .mat-expansion-panel-header:hover {
3999 background: mat-color($background, card);
4000 }
4001 }
4002
4003 .mat-expansion-panel-header-title {
4004 color: mat-color($foreground, text);
4005 }
4006
4007 .mat-expansion-panel-header-description,
4008 .mat-expansion-indicator::after {
4009 color: mat-color($foreground, secondary-text);
4010 }
4011
4012 .mat-expansion-panel-header[aria-disabled='true'] {
4013 color: mat-color($foreground, disabled-button);
4014
4015 .mat-expansion-panel-header-title,
4016 .mat-expansion-panel-header-description {
4017 color: inherit;
4018 }
4019 }
4020}
4021
4022@mixin mat-expansion-panel-typography($config-or-theme) {
4023 $config: mat-get-typography-config($config-or-theme);
4024 .mat-expansion-panel-header {
4025 font: {
4026 family: mat-font-family($config, subheading-1);
4027 size: mat-font-size($config, subheading-1);
4028 weight: mat-font-weight($config, subheading-1);
4029 }
4030 }
4031
4032 .mat-expansion-panel-content {
4033 @include mat-typography-level-to-styles($config, body-1);
4034 }
4035}
4036
4037@mixin mat-expansion-panel-density($config-or-theme) {
4038 $density-scale: mat-get-density-config($config-or-theme);
4039 $expanded-height: mat-private-density-prop-value(
4040 $mat-expansion-panel-header-density-config, $density-scale, expanded-height);
4041 $collapsed-height: mat-private-density-prop-value(
4042 $mat-expansion-panel-header-density-config, $density-scale, collapsed-height);
4043
4044 @include mat-private-density-legacy-compatibility() {
4045 .mat-expansion-panel-header {
4046 height: $collapsed-height;
4047
4048 &.mat-expanded {
4049 height: $expanded-height;
4050 }
4051 }
4052 }
4053}
4054
4055@mixin mat-expansion-panel-theme($theme-or-color-config) {
4056 $theme: mat-private-legacy-get-theme($theme-or-color-config);
4057 @include mat-private-check-duplicate-theme-styles($theme, 'mat-expansion-panel') {
4058 $color: mat-get-color-config($theme);
4059 $density: mat-get-density-config($theme);
4060 $typography: mat-get-typography-config($theme);
4061
4062 @if $color != null {
4063 @include mat-expansion-panel-color($color);
4064 }
4065 @if $density != null {
4066 @include mat-expansion-panel-density($density);
4067 }
4068 @if $typography != null {
4069 @include mat-expansion-panel-typography($typography);
4070 }
4071 }
4072}
4073
4074
4075
4076
4077// This mixin will ensure that lines that overflow the container will hide the overflow and
4078// truncate neatly with an ellipsis.
4079@mixin mat-truncate-line() {
4080 white-space: nowrap;
4081 overflow: hidden;
4082 text-overflow: ellipsis;
4083}
4084
4085// Mixin to provide all mat-line styles, changing secondary font size based on whether the list
4086// is in dense mode.
4087@mixin mat-line-base($secondary-font-size) {
4088 .mat-line {
4089 @include mat-truncate-line();
4090 display: block;
4091 box-sizing: border-box;
4092
4093 // all lines but the top line should have smaller text
4094 &:nth-child(n+2) {
4095 font-size: $secondary-font-size;
4096 }
4097 }
4098}
4099
4100// This mixin normalizes default element styles, e.g. font weight for heading text.
4101@mixin mat-normalize-text() {
4102 & > * {
4103 margin: 0;
4104 padding: 0;
4105 font-weight: normal;
4106 font-size: inherit;
4107 }
4108}
4109
4110// This mixin provides base styles for the wrapper around mat-line elements in a list.
4111@mixin mat-line-wrapper-base() {
4112 @include mat-normalize-text();
4113
4114 display: flex;
4115 flex-direction: column;
4116 flex: auto;
4117 box-sizing: border-box;
4118 overflow: hidden;
4119
4120 // Must remove wrapper when lines are empty or it takes up horizontal
4121 // space and pushes other elements to the right.
4122 &:empty {
4123 display: none;
4124 }
4125}
4126
4127
4128
4129// Include this empty mixin for consistency with the other components.
4130@mixin mat-grid-list-color($config-or-theme) {}
4131
4132@mixin mat-grid-list-typography($config-or-theme) {
4133 $config: mat-get-typography-config($config-or-theme);
4134 .mat-grid-tile-header,
4135 .mat-grid-tile-footer {
4136 @include mat-line-base(mat-font-size($config, caption));
4137 font-size: mat-font-size($config, body-1);
4138 }
4139}
4140
4141@mixin _mat-grid-list-density($config-or-theme) {}
4142
4143@mixin mat-grid-list-theme($theme-or-color-config) {
4144 $theme: mat-private-legacy-get-theme($theme-or-color-config);
4145 @include mat-private-check-duplicate-theme-styles($theme, 'mat-grid-list') {
4146 $color: mat-get-color-config($theme);
4147 $density: mat-get-density-config($theme);
4148 $typography: mat-get-typography-config($theme);
4149
4150 @if $color != null {
4151 @include mat-grid-list-color($color);
4152 }
4153 @if $density != null {
4154 @include _mat-grid-list-density($density);
4155 }
4156 @if $typography != null {
4157 @include mat-grid-list-typography($typography);
4158 }
4159 }
4160}
4161
4162
4163
4164@mixin mat-icon-color($config-or-theme) {
4165 $config: mat-get-color-config($config-or-theme);
4166 $primary: map-get($config, primary);
4167 $accent: map-get($config, accent);
4168 $warn: map-get($config, warn);
4169 $background: map-get($config, background);
4170 $foreground: map-get($config, foreground);
4171
4172 .mat-icon {
4173 &.mat-primary {
4174 color: mat-color($primary, text);
4175 }
4176
4177 &.mat-accent {
4178 color: mat-color($accent, text);
4179 }
4180
4181 &.mat-warn {
4182 color: mat-color($warn, text);
4183 }
4184 }
4185}
4186
4187@mixin mat-icon-typography($config-or-theme) {}
4188
4189@mixin _mat-icon-density($config-or-theme) {}
4190
4191@mixin mat-icon-theme($theme-or-color-config) {
4192 $theme: mat-private-legacy-get-theme($theme-or-color-config);
4193 @include mat-private-check-duplicate-theme-styles($theme, 'mat-icon') {
4194 $color: mat-get-color-config($theme);
4195 $density: mat-get-density-config($theme);
4196 $typography: mat-get-typography-config($theme);
4197
4198 @if $color != null {
4199 @include mat-icon-color($color);
4200 }
4201 @if $density != null {
4202 @include _mat-icon-density($density);
4203 }
4204 @if $typography != null {
4205 @include mat-icon-typography($typography);
4206 }
4207 }
4208}
4209
4210
4211
4212
4213
4214
4215// Renders a gradient for showing the dashed line when the input is disabled.
4216// Unlike using a border, a gradient allows us to adjust the spacing of the dotted line
4217// to match the Material Design spec.
4218@mixin mat-private-control-disabled-underline($color) {
4219 background-image: linear-gradient(to right, $color 0%, $color 33%, transparent 0%);
4220 background-size: 4px 100%;
4221 background-repeat: repeat-x;
4222}
4223
4224// Figures out the color of the placeholder for a form control.
4225// Used primarily to prevent the various form controls from
4226// becoming out of sync since these colors aren't in a palette.
4227@function mat-private-control-placeholder-color($config) {
4228 $foreground: map-get($config, foreground);
4229 $is-dark-theme: map-get($config, is-dark);
4230 @return mat-color($foreground, secondary-text, if($is-dark-theme, 0.5, 0.42));
4231}
4232
4233
4234/* stylelint-disable material/no-prefixes */
4235@mixin user-select($value) {
4236 -webkit-user-select: $value;
4237 -moz-user-select: $value;
4238 -ms-user-select: $value;
4239 user-select: $value;
4240}
4241
4242@mixin input-placeholder {
4243 &::placeholder {
4244 @content;
4245 }
4246
4247 &::-moz-placeholder {
4248 @content;
4249 }
4250
4251 &::-webkit-input-placeholder {
4252 @content;
4253 }
4254
4255 &:-ms-input-placeholder {
4256 @content;
4257 }
4258}
4259
4260@mixin cursor-grab {
4261 cursor: -webkit-grab;
4262 cursor: grab;
4263}
4264
4265@mixin cursor-grabbing {
4266 cursor: -webkit-grabbing;
4267 cursor: grabbing;
4268}
4269
4270@mixin backface-visibility($value) {
4271 -webkit-backface-visibility: $value;
4272 backface-visibility: $value;
4273}
4274
4275@mixin position-sticky($important: false) {
4276 position: -webkit-sticky #{if($important, '!important', '')};
4277 position: sticky #{if($important, '!important', '')};
4278}
4279/* stylelint-enable */
4280
4281
4282
4283@mixin mat-input-color($config-or-theme) {
4284 $config: mat-get-color-config($config-or-theme);
4285 $primary: map-get($config, primary);
4286 $accent: map-get($config, accent);
4287 $warn: map-get($config, warn);
4288 $foreground: map-get($config, foreground);
4289
4290 .mat-form-field-type-mat-native-select .mat-form-field-infix::after {
4291 color: mat-color($foreground, secondary-text);
4292 }
4293
4294 .mat-input-element:disabled,
4295 .mat-form-field-type-mat-native-select.mat-form-field-disabled .mat-form-field-infix::after {
4296 color: mat-color($foreground, disabled-text);
4297 }
4298
4299 .mat-input-element {
4300 caret-color: mat-color($primary, text);
4301
4302 @include input-placeholder {
4303 color: mat-private-control-placeholder-color($config);
4304 }
4305
4306 // On dark themes we set the native `select` color to some shade of white,
4307 // however the color propagates to all of the `option` elements, which are
4308 // always on a white background inside the dropdown, causing them to blend in.
4309 // Since we can't change background of the dropdown, we need to explicitly
4310 // reset the color of the options to something dark.
4311 @if (map-get($config, is-dark)) {
4312 option {
4313 color: $dark-primary-text;
4314 }
4315
4316 option:disabled {
4317 color: $dark-disabled-text;
4318 }
4319 }
4320 }
4321
4322 .mat-form-field.mat-accent .mat-input-element {
4323 caret-color: mat-color($accent, text);
4324 }
4325
4326 .mat-form-field.mat-warn .mat-input-element,
4327 .mat-form-field-invalid .mat-input-element {
4328 caret-color: mat-color($warn, text);
4329 }
4330
4331 .mat-form-field-type-mat-native-select.mat-form-field-invalid .mat-form-field-infix::after {
4332 color: mat-color($warn, text);
4333 }
4334}
4335
4336@mixin mat-input-typography($config-or-theme) {
4337 $config: mat-get-typography-config($config-or-theme);
4338 // The unit-less line-height from the font config.
4339 $line-height: mat-line-height($config, input);
4340
4341 // The amount of space between the top of the line and the top of the actual text
4342 // (as a fraction of the font-size).
4343 $line-spacing: ($line-height - 1) / 2;
4344
4345 // <input> elements seem to have their height set slightly too large on Safari causing the text to
4346 // be misaligned w.r.t. the placeholder. Adding this margin corrects it.
4347 input.mat-input-element {
4348 margin-top: -$line-spacing * 1em;
4349 }
4350}
4351
4352@mixin _mat-input-density($config-or-theme) {}
4353
4354@mixin mat-input-theme($theme-or-color-config) {
4355 $theme: mat-private-legacy-get-theme($theme-or-color-config);
4356 @include mat-private-check-duplicate-theme-styles($theme, 'mat-input') {
4357 $color: mat-get-color-config($theme);
4358 $density: mat-get-density-config($theme);
4359 $typography: mat-get-typography-config($theme);
4360
4361 @if $color != null {
4362 @include mat-input-color($color);
4363 }
4364 @if $density != null {
4365 @include _mat-input-density($density);
4366 }
4367 @if $typography != null {
4368 @include mat-input-typography($typography);
4369 }
4370 }
4371}
4372
4373
4374
4375
4376
4377
4378
4379@mixin mat-list-color($config-or-theme) {
4380 $config: mat-get-color-config($config-or-theme);
4381 $background: map-get($config, background);
4382 $foreground: map-get($config, foreground);
4383
4384 .mat-list-base {
4385 .mat-list-item {
4386 color: mat-color($foreground, text);
4387 }
4388
4389 .mat-list-option {
4390 color: mat-color($foreground, text);
4391 }
4392
4393 .mat-subheader {
4394 color: mat-color($foreground, secondary-text);
4395 }
4396 }
4397
4398 .mat-list-item-disabled {
4399 background-color: mat-color($background, disabled-list-option);
4400 }
4401
4402 .mat-list-option,
4403 .mat-nav-list .mat-list-item,
4404 .mat-action-list .mat-list-item {
4405 &:hover, &:focus {
4406 background: mat-color($background, 'hover');
4407 }
4408 }
4409
4410 .mat-list-single-selected-option {
4411 &, &:hover, &:focus {
4412 background: mat-color($background, hover, 0.12);
4413 }
4414 }
4415}
4416
4417@mixin mat-list-typography($config-or-theme) {
4418 $config: mat-get-typography-config($config-or-theme);
4419 $font-family: mat-font-family($config);
4420
4421 .mat-list-item {
4422 font-family: $font-family;
4423 }
4424
4425 .mat-list-option {
4426 font-family: $font-family;
4427 }
4428
4429 // Default list
4430 .mat-list-base {
4431 .mat-list-item {
4432 font-size: mat-font-size($config, subheading-2);
4433 @include mat-line-base(mat-font-size($config, body-1));
4434 }
4435
4436 .mat-list-option {
4437 font-size: mat-font-size($config, subheading-2);
4438 @include mat-line-base(mat-font-size($config, body-1));
4439 }
4440
4441 .mat-subheader {
4442 font-family: mat-font-family($config, body-2);
4443 font-size: mat-font-size($config, body-2);
4444 font-weight: mat-font-weight($config, body-2);
4445 }
4446 }
4447
4448 // Dense list
4449 .mat-list-base[dense] {
4450 .mat-list-item {
4451 font-size: mat-font-size($config, caption);
4452 @include mat-line-base(mat-font-size($config, caption));
4453 }
4454
4455 .mat-list-option {
4456 font-size: mat-font-size($config, caption);
4457 @include mat-line-base(mat-font-size($config, caption));
4458 }
4459
4460 .mat-subheader {
4461 font-family: $font-family;
4462 font-size: mat-font-size($config, caption);
4463 font-weight: mat-font-weight($config, body-2);
4464 }
4465 }
4466}
4467
4468@mixin _mat-list-density($config-or-theme) {}
4469
4470@mixin mat-list-theme($theme-or-color-config) {
4471 $theme: mat-private-legacy-get-theme($theme-or-color-config);
4472 @include mat-private-check-duplicate-theme-styles($theme, 'mat-list') {
4473 $color: mat-get-color-config($theme);
4474 $density: mat-get-density-config($theme);
4475 $typography: mat-get-typography-config($theme);
4476
4477 @if $color != null {
4478 @include mat-list-color($color);
4479 }
4480 @if $density != null {
4481 @include _mat-list-density($density);
4482 }
4483 @if $typography != null {
4484 @include mat-list-typography($typography);
4485 }
4486 }
4487}
4488
4489
4490
4491
4492
4493
4494
4495@mixin mat-menu-color($config-or-theme) {
4496 $config: mat-get-color-config($config-or-theme);
4497 $background: map-get($config, background);
4498 $foreground: map-get($config, foreground);
4499
4500 .mat-menu-panel {
4501 @include mat-private-theme-overridable-elevation(4, $config);
4502 background: mat-color($background, 'card');
4503 }
4504
4505 .mat-menu-item {
4506 background: transparent;
4507 color: mat-color($foreground, 'text');
4508
4509 &[disabled] {
4510 &,
4511 &::after,
4512 .mat-icon-no-color {
4513 color: mat-color($foreground, 'disabled');
4514 }
4515 }
4516 }
4517
4518 .mat-menu-item .mat-icon-no-color,
4519 .mat-menu-item-submenu-trigger::after {
4520 color: mat-color($foreground, 'icon');
4521 }
4522
4523 .mat-menu-item:hover,
4524 .mat-menu-item.cdk-program-focused,
4525 .mat-menu-item.cdk-keyboard-focused,
4526 .mat-menu-item-highlighted {
4527 &:not([disabled]) {
4528 background: mat-color($background, 'hover');
4529 }
4530 }
4531}
4532
4533@mixin mat-menu-typography($config-or-theme) {
4534 $config: mat-get-typography-config($config-or-theme);
4535 .mat-menu-item {
4536 font: {
4537 family: mat-font-family($config, body-1);
4538 size: mat-font-size($config, body-1);
4539 weight: mat-font-weight($config, body-1);
4540 }
4541 }
4542}
4543
4544@mixin _mat-menu-density($config-or-theme) {}
4545
4546@mixin mat-menu-theme($theme-or-color-config) {
4547 $theme: mat-private-legacy-get-theme($theme-or-color-config);
4548 @include mat-private-check-duplicate-theme-styles($theme, 'mat-menu') {
4549 $color: mat-get-color-config($theme);
4550 $density: mat-get-density-config($theme);
4551 $typography: mat-get-typography-config($theme);
4552
4553 @if $color != null {
4554 @include mat-menu-color($color);
4555 }
4556 @if $density != null {
4557 @include _mat-menu-density($density);
4558 }
4559 @if $typography != null {
4560 @include mat-menu-typography($typography);
4561 }
4562 }
4563}
4564
4565
4566
4567
4568
4569
4570$mat-paginator-height: 56px !default;
4571// Minimum height for paginator's in the highest density is determined based on how
4572// much the paginator can shrink until the content exceeds (i.e. navigation buttons).
4573$mat-paginator-minimum-height: 40px !default;
4574$mat-paginator-maximum-height: $mat-paginator-height !default;
4575
4576$mat-paginator-density-config: (
4577 height: (
4578 default: $mat-paginator-height,
4579 maximum: $mat-paginator-maximum-height,
4580 minimum: $mat-paginator-minimum-height,
4581 )
4582) !default;
4583
4584
4585@mixin mat-paginator-color($config-or-theme) {
4586 $config: mat-get-color-config($config-or-theme);
4587 $foreground: map-get($config, foreground);
4588 $background: map-get($config, background);
4589
4590 .mat-paginator {
4591 background: mat-color($background, 'card');
4592 }
4593
4594 .mat-paginator,
4595 .mat-paginator-page-size .mat-select-trigger {
4596 color: mat-color($foreground, secondary-text);
4597 }
4598
4599 .mat-paginator-decrement,
4600 .mat-paginator-increment {
4601 border-top: 2px solid mat-color($foreground, 'icon');
4602 border-right: 2px solid mat-color($foreground, 'icon');
4603 }
4604
4605 .mat-paginator-first,
4606 .mat-paginator-last {
4607 border-top: 2px solid mat-color($foreground, 'icon');
4608 }
4609
4610 .mat-icon-button[disabled] {
4611 .mat-paginator-decrement,
4612 .mat-paginator-increment,
4613 .mat-paginator-first,
4614 .mat-paginator-last {
4615 border-color: mat-color($foreground, 'disabled');
4616 }
4617 }
4618}
4619
4620@mixin mat-paginator-typography($config-or-theme) {
4621 $config: mat-get-typography-config($config-or-theme);
4622 .mat-paginator,
4623 .mat-paginator-page-size .mat-select-trigger {
4624 font: {
4625 family: mat-font-family($config, caption);
4626 size: mat-font-size($config, caption);
4627 }
4628 }
4629}
4630
4631@mixin mat-paginator-density($config-or-theme) {
4632 $density-scale: mat-get-density-config($config-or-theme);
4633 $height: mat-private-density-prop-value($mat-paginator-density-config, $density-scale, height);
4634
4635 @include mat-private-density-legacy-compatibility() {
4636 .mat-paginator-container {
4637 min-height: $height;
4638 }
4639 }
4640}
4641
4642@mixin mat-paginator-theme($theme-or-color-config) {
4643 $theme: mat-private-legacy-get-theme($theme-or-color-config);
4644 @include mat-private-check-duplicate-theme-styles($theme, 'mat-paginator') {
4645 $color: mat-get-color-config($theme);
4646 $density: mat-get-density-config($theme);
4647 $typography: mat-get-typography-config($theme);
4648
4649 @if $color != null {
4650 @include mat-paginator-color($color);
4651 }
4652 @if $density != null {
4653 @include mat-paginator-density($density);
4654 }
4655 @if $typography != null {
4656 @include mat-paginator-typography($typography);
4657 }
4658 }
4659}
4660
4661
4662
4663
4664@mixin mat-progress-bar-color($config-or-theme) {
4665 $config: mat-get-color-config($config-or-theme);
4666 $primary: map-get($config, primary);
4667 $accent: map-get($config, accent);
4668 $warn: map-get($config, warn);
4669
4670 .mat-progress-bar-background {
4671 fill: mat-color($primary, lighter);
4672 }
4673
4674 .mat-progress-bar-buffer {
4675 background-color: mat-color($primary, lighter);
4676 }
4677
4678 .mat-progress-bar-fill::after {
4679 background-color: mat-color($primary);
4680 }
4681
4682 .mat-progress-bar.mat-accent {
4683 .mat-progress-bar-background {
4684 fill: mat-color($accent, lighter);
4685 }
4686
4687 .mat-progress-bar-buffer {
4688 background-color: mat-color($accent, lighter);
4689 }
4690
4691 .mat-progress-bar-fill::after {
4692 background-color: mat-color($accent);
4693 }
4694 }
4695
4696 .mat-progress-bar.mat-warn {
4697 .mat-progress-bar-background {
4698 fill: mat-color($warn, lighter);
4699 }
4700
4701 .mat-progress-bar-buffer {
4702 background-color: mat-color($warn, lighter);
4703 }
4704
4705 .mat-progress-bar-fill::after {
4706 background-color: mat-color($warn);
4707 }
4708 }
4709}
4710
4711@mixin mat-progress-bar-typography($config-or-theme) {}
4712
4713@mixin _mat-progress-bar-density($config-or-theme) {}
4714
4715@mixin mat-progress-bar-theme($theme-or-color-config) {
4716 $theme: mat-private-legacy-get-theme($theme-or-color-config);
4717 @include mat-private-check-duplicate-theme-styles($theme, 'mat-progress-bar') {
4718 $color: mat-get-color-config($theme);
4719 $density: mat-get-density-config($theme);
4720 $typography: mat-get-typography-config($theme);
4721
4722 @if $color != null {
4723 @include mat-progress-bar-color($color);
4724 }
4725 @if $density != null {
4726 @include _mat-progress-bar-density($density);
4727 }
4728 @if $typography != null {
4729 @include mat-progress-bar-typography($typography);
4730 }
4731 }
4732}
4733
4734
4735
4736
4737
4738@mixin mat-progress-spinner-color($config-or-theme) {
4739 $config: mat-get-color-config($config-or-theme);
4740 $primary: map-get($config, primary);
4741 $accent: map-get($config, accent);
4742 $warn: map-get($config, warn);
4743
4744 .mat-progress-spinner, .mat-spinner {
4745 circle {
4746 stroke: mat-color($primary);
4747 }
4748
4749 &.mat-accent circle {
4750 stroke: mat-color($accent);
4751 }
4752
4753 &.mat-warn circle {
4754 stroke: mat-color($warn);
4755 }
4756 }
4757}
4758
4759@mixin mat-progress-spinner-typography($config-or-theme) {}
4760
4761@mixin _mat-progress-spinner-density($config-or-theme) {}
4762
4763@mixin mat-progress-spinner-theme($theme-or-color-config) {
4764 $theme: mat-private-legacy-get-theme($theme-or-color-config);
4765 @include mat-private-check-duplicate-theme-styles($theme, 'mat-progress-spinner') {
4766 $color: mat-get-color-config($theme);
4767 $density: mat-get-density-config($theme);
4768 $typography: mat-get-typography-config($theme);
4769
4770 @if $color != null {
4771 @include mat-progress-spinner-color($color);
4772 }
4773 @if $density != null {
4774 @include _mat-progress-spinner-density($density);
4775 }
4776 @if $typography != null {
4777 @include mat-progress-spinner-typography($typography);
4778 }
4779 }
4780}
4781
4782
4783
4784
4785
4786@mixin _mat-radio-color($palette) {
4787 &.mat-radio-checked .mat-radio-outer-circle {
4788 border-color: mat-color($palette);
4789 }
4790
4791 .mat-radio-inner-circle,
4792 .mat-radio-ripple .mat-ripple-element:not(.mat-radio-persistent-ripple),
4793 &.mat-radio-checked .mat-radio-persistent-ripple,
4794 &:active .mat-radio-persistent-ripple {
4795 background-color: mat-color($palette);
4796 }
4797}
4798
4799@mixin mat-radio-color($config-or-theme) {
4800 $config: mat-get-color-config($config-or-theme);
4801 $primary: map-get($config, primary);
4802 $accent: map-get($config, accent);
4803 $warn: map-get($config, warn);
4804 $background: map-get($config, background);
4805 $foreground: map-get($config, foreground);
4806
4807 .mat-radio-outer-circle {
4808 border-color: mat-color($foreground, secondary-text);
4809 }
4810
4811 .mat-radio-button {
4812 &.mat-primary {
4813 @include _mat-radio-color($primary);
4814 }
4815
4816 &.mat-accent {
4817 @include _mat-radio-color($accent);
4818 }
4819
4820 &.mat-warn {
4821 @include _mat-radio-color($warn);
4822 }
4823
4824 // This needs extra specificity, because the classes above are combined
4825 // (e.g. `.mat-radio-button.mat-accent`) which increases their specificity a lot.
4826 // TODO: consider making the selectors into descendants (`.mat-primary .mat-radio-button`).
4827 &.mat-radio-disabled {
4828 &.mat-radio-checked .mat-radio-outer-circle,
4829 .mat-radio-outer-circle {
4830 border-color: mat-color($foreground, disabled);
4831 }
4832
4833 .mat-radio-ripple .mat-ripple-element,
4834 .mat-radio-inner-circle {
4835 background-color: mat-color($foreground, disabled);
4836 }
4837
4838 .mat-radio-label-content {
4839 color: mat-color($foreground, disabled);
4840 }
4841 }
4842
4843 // Switch this to a solid color since we're using `opacity`
4844 // to control how opaque the ripple should be.
4845 .mat-ripple-element {
4846 background-color: map-get($foreground, base);
4847 }
4848 }
4849}
4850
4851@mixin mat-radio-typography($config-or-theme) {
4852 $config: mat-get-typography-config($config-or-theme);
4853 .mat-radio-button {
4854 font-family: mat-font-family($config);
4855 }
4856}
4857
4858@mixin _mat-radio-density($config-or-theme) {}
4859
4860@mixin mat-radio-theme($theme-or-color-config) {
4861 $theme: mat-private-legacy-get-theme($theme-or-color-config);
4862 @include mat-private-check-duplicate-theme-styles($theme, 'mat-radio') {
4863 $color: mat-get-color-config($theme);
4864 $density: mat-get-density-config($theme);
4865 $typography: mat-get-typography-config($theme);
4866
4867 @if $color != null {
4868 @include mat-radio-color($color);
4869 }
4870 @if $density != null {
4871 @include _mat-radio-density($density);
4872 }
4873 @if $typography != null {
4874 @include mat-radio-typography($typography);
4875 }
4876 }
4877}
4878
4879
4880
4881
4882
4883
4884
4885
4886@mixin mat-select-color($config-or-theme) {
4887 $config: mat-get-color-config($config-or-theme);
4888 $foreground: map-get($config, foreground);
4889 $background: map-get($config, background);
4890 $primary: map-get($config, primary);
4891 $accent: map-get($config, accent);
4892 $warn: map-get($config, warn);
4893
4894 .mat-select-value {
4895 color: mat-color($foreground, text);
4896 }
4897
4898 .mat-select-placeholder {
4899 color: mat-private-control-placeholder-color($config);
4900 }
4901
4902 .mat-select-disabled .mat-select-value {
4903 color: mat-color($foreground, disabled-text);
4904 }
4905
4906 .mat-select-arrow {
4907 color: mat-color($foreground, secondary-text);
4908 }
4909
4910 .mat-select-panel {
4911 background: mat-color($background, card);
4912 @include mat-private-theme-overridable-elevation(4, $config);
4913
4914 .mat-option.mat-selected:not(.mat-option-multiple) {
4915 background: mat-color($background, hover, 0.12);
4916 }
4917 }
4918
4919 .mat-form-field {
4920 &.mat-focused {
4921 &.mat-primary .mat-select-arrow {
4922 color: mat-color($primary, text);
4923 }
4924
4925 &.mat-accent .mat-select-arrow {
4926 color: mat-color($accent, text);
4927 }
4928
4929 &.mat-warn .mat-select-arrow {
4930 color: mat-color($warn, text);
4931 }
4932 }
4933
4934 .mat-select.mat-select-invalid .mat-select-arrow {
4935 color: mat-color($warn, text);
4936 }
4937
4938 .mat-select.mat-select-disabled .mat-select-arrow {
4939 color: mat-color($foreground, disabled-text);
4940 }
4941 }
4942}
4943
4944@mixin mat-select-typography($config-or-theme) {
4945 $config: mat-get-typography-config($config-or-theme);
4946 // The unit-less line-height from the font config.
4947 $line-height: mat-line-height($config, input);
4948
4949 .mat-select {
4950 font-family: mat-font-family($config);
4951 }
4952
4953 .mat-select-trigger {
4954 height: $line-height * 1em;
4955 }
4956}
4957
4958@mixin _mat-select-density($config-or-theme) {}
4959
4960@mixin mat-select-theme($theme-or-color-config) {
4961 $theme: mat-private-legacy-get-theme($theme-or-color-config);
4962 @include mat-private-check-duplicate-theme-styles($theme, 'mat-select') {
4963 $color: mat-get-color-config($theme);
4964 $density: mat-get-density-config($theme);
4965 $typography: mat-get-typography-config($theme);
4966
4967 @if $color != null {
4968 @include mat-select-color($color);
4969 }
4970 @if $density != null {
4971 @include _mat-select-density($density);
4972 }
4973 @if $typography != null {
4974 @include mat-select-typography($typography);
4975 }
4976 }
4977}
4978
4979
4980
4981
4982
4983@mixin mat-sidenav-color($config-or-theme) {
4984 $config: mat-get-color-config($config-or-theme);
4985 $primary: map-get($config, primary);
4986 $accent: map-get($config, accent);
4987 $warn: map-get($config, warn);
4988 $background: map-get($config, background);
4989 $foreground: map-get($config, foreground);
4990
4991 $drawer-background-color: mat-color($background, dialog);
4992 $drawer-container-background-color: mat-color($background, background);
4993 $drawer-push-background-color: mat-color($background, dialog);
4994 $drawer-side-border: solid 1px mat-color($foreground, divider);
4995
4996 .mat-drawer-container {
4997 background-color: $drawer-container-background-color;
4998 color: mat-color($foreground, text);
4999 }
5000
5001 .mat-drawer {
5002 background-color: $drawer-background-color;
5003 color: mat-color($foreground, text);
5004
5005 &.mat-drawer-push {
5006 background-color: $drawer-push-background-color;
5007 }
5008
5009 &:not(.mat-drawer-side) {
5010 // The elevation of z-16 is noted in the design specifications.
5011 // See https://material.io/design/components/navigation-drawer.html
5012 @include mat-private-theme-elevation(16, $config);
5013 }
5014 }
5015
5016 .mat-drawer-side {
5017 border-right: $drawer-side-border;
5018
5019 &.mat-drawer-end {
5020 border-left: $drawer-side-border;
5021 border-right: none;
5022 }
5023 }
5024
5025 [dir='rtl'] .mat-drawer-side {
5026 border-left: $drawer-side-border;
5027 border-right: none;
5028
5029 &.mat-drawer-end {
5030 border-left: none;
5031 border-right: $drawer-side-border;
5032 }
5033 }
5034
5035 .mat-drawer-backdrop.mat-drawer-shown {
5036 $opacity: 0.6;
5037 $backdrop-color: mat-color($background, card, $opacity);
5038
5039 @if (type-of($backdrop-color) == color) {
5040 // We use invert() here to have the darken the background color expected to be used. If the
5041 // background is light, we use a dark backdrop. If the background is dark,
5042 // we use a light backdrop.
5043 background-color: invert($backdrop-color);
5044 }
5045 @else {
5046 // If we couldn't resolve the backdrop color to a color value, fall back to using
5047 // `opacity` to make it opaque since its end value could be a solid color.
5048 background-color: $backdrop-color;
5049 opacity: $opacity;
5050 }
5051 }
5052}
5053
5054@mixin mat-sidenav-typography($config-or-theme) {}
5055
5056@mixin _mat-sidenav-density($config-or-theme) {}
5057
5058@mixin mat-sidenav-theme($theme-or-color-config) {
5059 $theme: mat-private-legacy-get-theme($theme-or-color-config);
5060 @include mat-private-check-duplicate-theme-styles($theme, 'mat-sidenav') {
5061 $color: mat-get-color-config($theme);
5062 $density: mat-get-density-config($theme);
5063 $typography: mat-get-typography-config($theme);
5064
5065 @if $color != null {
5066 @include mat-sidenav-color($color);
5067 }
5068 @if $density != null {
5069 @include _mat-sidenav-density($density);
5070 }
5071 @if $typography != null {
5072 @include mat-sidenav-typography($typography);
5073 }
5074 }
5075}
5076
5077
5078
5079
5080
5081
5082@mixin _mat-slide-toggle-checked($palette, $thumb-checked-hue) {
5083 &.mat-checked {
5084 .mat-slide-toggle-thumb {
5085 background-color: mat-color($palette, $thumb-checked-hue);
5086 }
5087
5088 .mat-slide-toggle-bar {
5089 // Opacity is determined from the specs for the selection controls.
5090 // See: https://material.io/design/components/selection-controls.html#specs
5091 background-color: mat-color($palette, $thumb-checked-hue, 0.54);
5092 }
5093
5094 .mat-ripple-element {
5095 // Set no opacity for the ripples because the ripple opacity will be adjusted dynamically
5096 // based on the type of interaction with the slide-toggle (e.g. for hover, focus)
5097 background-color: mat-color($palette, $thumb-checked-hue);
5098 }
5099 }
5100}
5101
5102@mixin mat-slide-toggle-color($config-or-theme) {
5103 $config: mat-get-color-config($config-or-theme);
5104 $is-dark: map-get($config, is-dark);
5105 $primary: map-get($config, primary);
5106 $accent: map-get($config, accent);
5107 $warn: map-get($config, warn);
5108 $background: map-get($config, background);
5109 $foreground: map-get($config, foreground);
5110
5111 // Color hues are based on the specs which briefly show the hues that are applied to a switch.
5112 // The 2018 specs no longer describe how dark switches should look like. Due to the lack of
5113 // information for dark themed switches, we partially keep the old behavior that is based on
5114 // the previous specifications. For the checked color we always use the `default` hue because
5115 // that follows MDC and also makes it easier for people to create a custom theme without needing
5116 // to specify each hue individually.
5117 $thumb-unchecked-hue: if($is-dark, 400, 50);
5118 $thumb-checked-hue: default;
5119
5120 $bar-unchecked-color: mat-color($foreground, disabled);
5121 $ripple-unchecked-color: mat-color($foreground, base);
5122
5123 .mat-slide-toggle {
5124 @include _mat-slide-toggle-checked($accent, $thumb-checked-hue);
5125
5126 &.mat-primary {
5127 @include _mat-slide-toggle-checked($primary, $thumb-checked-hue);
5128 }
5129
5130 &.mat-warn {
5131 @include _mat-slide-toggle-checked($warn, $thumb-checked-hue);
5132 }
5133
5134 &:not(.mat-checked) .mat-ripple-element {
5135 // Set no opacity for the ripples because the ripple opacity will be adjusted dynamically
5136 // based on the type of interaction with the slide-toggle (e.g. for hover, focus)
5137 background-color: $ripple-unchecked-color;
5138 }
5139 }
5140
5141 .mat-slide-toggle-thumb {
5142 @include mat-private-theme-elevation(1, $config);
5143 background-color: mat-color($mat-grey, $thumb-unchecked-hue);
5144 }
5145
5146 .mat-slide-toggle-bar {
5147 background-color: $bar-unchecked-color;
5148 }
5149}
5150
5151@mixin mat-slide-toggle-typography($config-or-theme) {
5152 $config: mat-get-typography-config($config-or-theme);
5153 .mat-slide-toggle-content {
5154 font-family: mat-font-family($config);
5155 }
5156}
5157
5158@mixin _mat-slide-toggle-density($config-or-theme) {}
5159
5160@mixin mat-slide-toggle-theme($theme-or-color-config) {
5161 $theme: mat-private-legacy-get-theme($theme-or-color-config);
5162 @include mat-private-check-duplicate-theme-styles($theme, 'mat-slide-toggle') {
5163 $color: mat-get-color-config($theme);
5164 $density: mat-get-density-config($theme);
5165 $typography: mat-get-typography-config($theme);
5166
5167 @if $color != null {
5168 @include mat-slide-toggle-color($color);
5169 }
5170 @if $density != null {
5171 @include _mat-slide-toggle-density($density);
5172 }
5173 @if $typography != null {
5174 @include mat-slide-toggle-typography($typography);
5175 }
5176 }
5177}
5178
5179
5180
5181
5182
5183
5184@mixin _mat-slider-inner-content-theme($palette) {
5185 .mat-slider-track-fill,
5186 .mat-slider-thumb,
5187 .mat-slider-thumb-label {
5188 background-color: mat-color($palette);
5189 }
5190
5191 .mat-slider-thumb-label-text {
5192 color: mat-color($palette, default-contrast);
5193 }
5194
5195 .mat-slider-focus-ring {
5196 $opacity: 0.2;
5197 $color: mat-color($palette, default, $opacity);
5198 background-color: $color;
5199
5200 // `mat-color` uses `rgba` for the opacity which won't work with
5201 // CSS variables so we need to use `opacity` as a fallback.
5202 @if (type-of($color) != color) {
5203 opacity: $opacity;
5204 }
5205 }
5206}
5207
5208@mixin mat-slider-color($config-or-theme) {
5209 $config: mat-get-color-config($config-or-theme);
5210 $primary: map-get($config, primary);
5211 $accent: map-get($config, accent);
5212 $warn: map-get($config, warn);
5213 $background: map-get($config, background);
5214 $foreground: map-get($config, foreground);
5215
5216 $mat-slider-off-color: mat-color($foreground, slider-off);
5217 $mat-slider-off-focused-color: mat-color($foreground, slider-off-active);
5218 $mat-slider-disabled-color: mat-color($foreground, slider-off);
5219 $mat-slider-labeled-min-value-thumb-color: mat-color($foreground, slider-min);
5220 $mat-slider-labeled-min-value-thumb-label-color: mat-color($foreground, slider-off);
5221 $mat-slider-tick-opacity: 0.7;
5222 $mat-slider-tick-color: mat-color($foreground, base, $mat-slider-tick-opacity);
5223 $mat-slider-tick-size: 2px;
5224
5225 .mat-slider-track-background {
5226 background-color: $mat-slider-off-color;
5227 }
5228
5229 .mat-primary {
5230 @include _mat-slider-inner-content-theme($primary);
5231 }
5232
5233 .mat-accent {
5234 @include _mat-slider-inner-content-theme($accent);
5235 }
5236
5237 .mat-warn {
5238 @include _mat-slider-inner-content-theme($warn);
5239 }
5240
5241 .mat-slider:hover,
5242 .cdk-focused {
5243 .mat-slider-track-background {
5244 background-color: $mat-slider-off-focused-color;
5245 }
5246 }
5247
5248 .mat-slider-disabled {
5249 .mat-slider-track-background,
5250 .mat-slider-track-fill,
5251 .mat-slider-thumb {
5252 background-color: $mat-slider-disabled-color;
5253 }
5254
5255 &:hover {
5256 .mat-slider-track-background {
5257 background-color: $mat-slider-disabled-color;
5258 }
5259 }
5260 }
5261
5262 .mat-slider-min-value {
5263 .mat-slider-focus-ring {
5264 $opacity: 0.12;
5265 $color: mat-color($foreground, base, $opacity);
5266 background-color: $color;
5267
5268 // `mat-color` uses `rgba` for the opacity which won't work with
5269 // CSS variables so we need to use `opacity` as a fallback.
5270 @if (type-of($color) != color) {
5271 opacity: $opacity;
5272 }
5273 }
5274
5275 &.mat-slider-thumb-label-showing {
5276 .mat-slider-thumb,
5277 .mat-slider-thumb-label {
5278 background-color: $mat-slider-labeled-min-value-thumb-color;
5279 }
5280
5281 &.cdk-focused {
5282 .mat-slider-thumb,
5283 .mat-slider-thumb-label {
5284 background-color: $mat-slider-labeled-min-value-thumb-label-color;
5285 }
5286 }
5287 }
5288
5289 &:not(.mat-slider-thumb-label-showing) {
5290 .mat-slider-thumb {
5291 border-color: $mat-slider-off-color;
5292 background-color: transparent;
5293 }
5294
5295 &:hover,
5296 &.cdk-focused {
5297 .mat-slider-thumb {
5298 border-color: $mat-slider-off-focused-color;
5299 }
5300
5301 &.mat-slider-disabled .mat-slider-thumb {
5302 border-color: $mat-slider-disabled-color;
5303 }
5304 }
5305 }
5306 }
5307
5308 .mat-slider-has-ticks .mat-slider-wrapper::after {
5309 border-color: $mat-slider-tick-color;
5310
5311 // `mat-color` uses `rgba` for the opacity which won't work with
5312 // CSS variables so we need to use `opacity` as a fallback.
5313 @if (type-of($mat-slider-tick-color) != color) {
5314 opacity: $mat-slider-tick-opacity;
5315 }
5316 }
5317
5318 .mat-slider-horizontal .mat-slider-ticks {
5319 background-image: repeating-linear-gradient(to right, $mat-slider-tick-color,
5320 $mat-slider-tick-color $mat-slider-tick-size, transparent 0, transparent);
5321 // Firefox doesn't draw the gradient correctly with 'to right'
5322 // (see https://bugzilla.mozilla.org/show_bug.cgi?id=1314319).
5323 background-image: -moz-repeating-linear-gradient(0.0001deg, $mat-slider-tick-color,
5324 $mat-slider-tick-color $mat-slider-tick-size, transparent 0, transparent);
5325
5326 // `mat-color` uses `rgba` for the opacity which won't work with
5327 // CSS variables so we need to use `opacity` as a fallback.
5328 @if (type-of($mat-slider-tick-color) != color) {
5329 opacity: $mat-slider-tick-opacity;
5330 }
5331 }
5332
5333 .mat-slider-vertical .mat-slider-ticks {
5334 background-image: repeating-linear-gradient(to bottom, $mat-slider-tick-color,
5335 $mat-slider-tick-color $mat-slider-tick-size, transparent 0, transparent);
5336
5337 // `mat-color` uses `rgba` for the opacity which won't work with
5338 // CSS variables so we need to use `opacity` as a fallback.
5339 @if (type-of($mat-slider-tick-color) != color) {
5340 opacity: $mat-slider-tick-opacity;
5341 }
5342 }
5343}
5344
5345@mixin mat-slider-typography($config-or-theme) {
5346 $config: mat-get-typography-config($config-or-theme);
5347 .mat-slider-thumb-label-text {
5348 font: {
5349 family: mat-font-family($config);
5350 size: mat-font-size($config, caption);
5351 weight: mat-font-weight($config, body-2);
5352 }
5353 }
5354}
5355
5356@mixin _mat-slider-density($config-or-theme) {}
5357
5358@mixin mat-slider-theme($theme-or-color-config) {
5359 $theme: mat-private-legacy-get-theme($theme-or-color-config);
5360 @include mat-private-check-duplicate-theme-styles($theme, 'mat-slider') {
5361 $color: mat-get-color-config($theme);
5362 $density: mat-get-density-config($theme);
5363 $typography: mat-get-typography-config($theme);
5364
5365 @if $color != null {
5366 @include mat-slider-color($color);
5367 }
5368 @if $density != null {
5369 @include _mat-slider-density($density);
5370 }
5371 @if $typography != null {
5372 @include mat-slider-typography($typography);
5373 }
5374 }
5375}
5376
5377
5378
5379
5380
5381$mat-stepper-header-height: 72px !default;
5382// Minimum height for highest density stepper's is determined based on how much
5383// stepper headers can shrink until the step icon or step label exceed. We can't use
5384// a value below `42px` because the optional label for steps would otherwise exceed.
5385$mat-stepper-header-minimum-height: 42px !default;
5386$mat-stepper-header-maximum-height: $mat-stepper-header-height !default;
5387
5388$mat-stepper-density-config: (
5389 height: (
5390 default: $mat-stepper-header-height,
5391 maximum: $mat-stepper-header-maximum-height,
5392 minimum: $mat-stepper-header-minimum-height,
5393 )
5394) !default;
5395
5396// Note: These variables are not denoted with `!default` because they are used in the non-theme
5397// component styles. Modifying these variables does not have the desired effect for consumers.
5398$mat-stepper-label-header-height: 24px;
5399$mat-stepper-label-position-bottom-top-gap: 16px;
5400$mat-stepper-label-min-width: 50px;
5401
5402$mat-vertical-stepper-content-margin: 36px;
5403
5404$mat-stepper-side-gap: 24px;
5405$mat-stepper-line-width: 1px;
5406$mat-stepper-line-gap: 8px;
5407
5408$mat-step-sub-label-font-size: 12px;
5409$mat-step-header-icon-size: 16px;
5410
5411
5412@mixin mat-stepper-color($config-or-theme) {
5413 $config: mat-get-color-config($config-or-theme);
5414 $foreground: map-get($config, foreground);
5415 $background: map-get($config, background);
5416 $primary: map-get($config, primary);
5417 $accent: map-get($config, accent);
5418 $warn: map-get($config, warn);
5419
5420 .mat-step-header {
5421 &.cdk-keyboard-focused,
5422 &.cdk-program-focused,
5423 &:hover {
5424 background-color: mat-color($background, hover);
5425 }
5426
5427 // On touch devices the :hover state will linger on the element after a tap.
5428 // Reset it via `@media` after the declaration, because the media query isn't
5429 // supported by all browsers yet.
5430 @media (hover: none) {
5431 &:hover {
5432 background: none;
5433 }
5434 }
5435
5436 .mat-step-label,
5437 .mat-step-optional {
5438 // TODO(josephperrott): Update to using a corrected disabled-text contrast
5439 // instead of secondary-text.
5440 color: mat-color($foreground, secondary-text);
5441 }
5442
5443 .mat-step-icon {
5444 // TODO(josephperrott): Update to using a corrected disabled-text contrast
5445 // instead of secondary-text.
5446 background-color: mat-color($foreground, secondary-text);
5447 color: mat-color($primary, default-contrast);
5448 }
5449
5450 .mat-step-icon-selected,
5451 .mat-step-icon-state-done,
5452 .mat-step-icon-state-edit {
5453 background-color: mat-color($primary);
5454 color: mat-color($primary, default-contrast);
5455 }
5456
5457 &.mat-accent {
5458 .mat-step-icon {
5459 color: mat-color($accent, default-contrast);
5460 }
5461
5462 .mat-step-icon-selected,
5463 .mat-step-icon-state-done,
5464 .mat-step-icon-state-edit {
5465 background-color: mat-color($accent);
5466 color: mat-color($accent, default-contrast);
5467 }
5468 }
5469
5470 &.mat-warn {
5471 .mat-step-icon {
5472 color: mat-color($warn, default-contrast);
5473 }
5474
5475 .mat-step-icon-selected,
5476 .mat-step-icon-state-done,
5477 .mat-step-icon-state-edit {
5478 background-color: mat-color($warn);
5479 color: mat-color($warn, default-contrast);
5480 }
5481 }
5482
5483 .mat-step-icon-state-error {
5484 background-color: transparent;
5485 color: mat-color($warn, text);
5486 }
5487
5488 .mat-step-label.mat-step-label-active {
5489 color: mat-color($foreground, text);
5490 }
5491
5492 .mat-step-label.mat-step-label-error {
5493 color: mat-color($warn, text);
5494 }
5495 }
5496
5497 .mat-stepper-horizontal, .mat-stepper-vertical {
5498 background-color: mat-color($background, card);
5499 }
5500
5501 .mat-stepper-vertical-line::before {
5502 border-left-color: mat-color($foreground, divider);
5503 }
5504
5505 .mat-horizontal-stepper-header::before,
5506 .mat-horizontal-stepper-header::after,
5507 .mat-stepper-horizontal-line {
5508 border-top-color: mat-color($foreground, divider);
5509 }
5510}
5511
5512@mixin mat-stepper-typography($config-or-theme) {
5513 $config: mat-get-typography-config($config-or-theme);
5514 .mat-stepper-vertical, .mat-stepper-horizontal {
5515 font-family: mat-font-family($config);
5516 }
5517
5518 .mat-step-label {
5519 font: {
5520 size: mat-font-size($config, body-1);
5521 weight: mat-font-weight($config, body-1);
5522 };
5523 }
5524
5525 .mat-step-sub-label-error {
5526 font-weight: normal;
5527 }
5528
5529 .mat-step-label-error {
5530 font-size: mat-font-size($config, body-2);
5531 }
5532
5533 .mat-step-label-selected {
5534 font: {
5535 size: mat-font-size($config, body-2);
5536 weight: mat-font-weight($config, body-2);
5537 };
5538 }
5539}
5540
5541@mixin mat-stepper-density($config-or-theme) {
5542 $density-scale: mat-get-density-config($config-or-theme);
5543 $height: mat-private-density-prop-value($mat-stepper-density-config, $density-scale, height);
5544 $vertical-padding: ($height - $mat-stepper-label-header-height) / 2;
5545
5546 @include mat-private-density-legacy-compatibility() {
5547 .mat-horizontal-stepper-header {
5548 height: $height;
5549 }
5550
5551 .mat-stepper-label-position-bottom .mat-horizontal-stepper-header,
5552 .mat-vertical-stepper-header {
5553 padding: $vertical-padding $mat-stepper-side-gap;
5554 }
5555
5556 // Ensures that the vertical lines for the step content exceed into the step
5557 // headers with a given distance (`$mat-stepper-line-gap`) to the step icon.
5558 .mat-stepper-vertical-line::before {
5559 top: $mat-stepper-line-gap - $vertical-padding;
5560 bottom: $mat-stepper-line-gap - $vertical-padding;
5561 }
5562
5563 // Ensures that the horizontal lines for the step header are centered vertically.
5564 .mat-stepper-label-position-bottom .mat-horizontal-stepper-header {
5565 &::after, &::before {
5566 top: $vertical-padding + $mat-stepper-label-header-height / 2;
5567 }
5568 }
5569
5570 // Ensures that the horizontal line for the step content is aligned centered vertically.
5571 .mat-stepper-label-position-bottom .mat-stepper-horizontal-line {
5572 top: $vertical-padding + $mat-stepper-label-header-height / 2;
5573 }
5574 }
5575}
5576
5577@mixin mat-stepper-theme($theme-or-color-config) {
5578 $theme: mat-private-legacy-get-theme($theme-or-color-config);
5579 @include mat-private-check-duplicate-theme-styles($theme, 'mat-stepper') {
5580 $color: mat-get-color-config($theme);
5581 $density: mat-get-density-config($theme);
5582 $typography: mat-get-typography-config($theme);
5583
5584 @if $color != null {
5585 @include mat-stepper-color($color);
5586 }
5587 @if $density != null {
5588 @include mat-stepper-density($density);
5589 }
5590 @if $typography != null {
5591 @include mat-stepper-typography($typography);
5592 }
5593 }
5594}
5595
5596
5597
5598@mixin mat-sort-color($config-or-theme) {
5599 $config: mat-get-color-config($config-or-theme);
5600 $background: map-get($config, background);
5601 $foreground: map-get($config, foreground);
5602
5603 .mat-sort-header-arrow {
5604 $table-background: mat-color($background, 'card');
5605 $text-color: mat-color($foreground, secondary-text);
5606
5607 // Because the arrow is made up of multiple elements that are stacked on top of each other,
5608 // we can't use the semi-transparent color from the theme directly. If the value is a color
5609 // *type*, we convert it into a solid color by taking the opacity from the rgba value and
5610 // using the value to determine the percentage of the background to put into foreground
5611 // when mixing the colors together. Otherwise, if it resolves to something different
5612 // (e.g. it resolves to a CSS variable), we use the color directly.
5613 @if (type-of($table-background) == color and type-of($text-color) == color) {
5614 $text-opacity: opacity($text-color);
5615 color: mix($table-background, rgba($text-color, 1), (1 - $text-opacity) * 100%);
5616 }
5617 @else {
5618 color: $text-color;
5619 }
5620 }
5621}
5622
5623@mixin mat-sort-typography($config-or-theme) {}
5624
5625@mixin _mat-sort-density($config-or-theme) {}
5626
5627@mixin mat-sort-theme($theme-or-color-config) {
5628 $theme: mat-private-legacy-get-theme($theme-or-color-config);
5629 @include mat-private-check-duplicate-theme-styles($theme, 'mat-sort') {
5630 $color: mat-get-color-config($theme);
5631 $density: mat-get-density-config($theme);
5632 $typography: mat-get-typography-config($theme);
5633
5634 @if $color != null {
5635 @include mat-sort-color($color);
5636 }
5637 @if $density != null {
5638 @include _mat-sort-density($density);
5639 }
5640 @if $typography != null {
5641 @include mat-sort-typography($typography);
5642 }
5643 }
5644}
5645
5646
5647
5648
5649
5650@mixin mat-tabs-color($config-or-theme) {
5651 $config: mat-get-color-config($config-or-theme);
5652 $primary: map-get($config, primary);
5653 $accent: map-get($config, accent);
5654 $warn: map-get($config, warn);
5655 $background: map-get($config, background);
5656 $foreground: map-get($config, foreground);
5657 $header-border: 1px solid mat-color($foreground, divider);
5658
5659 .mat-tab-nav-bar,
5660 .mat-tab-header {
5661 border-bottom: $header-border;
5662 }
5663
5664 .mat-tab-group-inverted-header {
5665 .mat-tab-nav-bar,
5666 .mat-tab-header {
5667 border-top: $header-border;
5668 border-bottom: none;
5669 }
5670 }
5671
5672 .mat-tab-label, .mat-tab-link {
5673 color: mat-color($foreground, text);
5674
5675 &.mat-tab-disabled {
5676 color: mat-color($foreground, disabled-text);
5677 }
5678 }
5679
5680 .mat-tab-header-pagination-chevron {
5681 border-color: mat-color($foreground, text);
5682 }
5683
5684 .mat-tab-header-pagination-disabled .mat-tab-header-pagination-chevron {
5685 border-color: mat-color($foreground, disabled-text);
5686 }
5687
5688 // Remove header border when there is a background color
5689 .mat-tab-group[class*='mat-background-'] .mat-tab-header,
5690 .mat-tab-nav-bar[class*='mat-background-'] {
5691 border-bottom: none;
5692 border-top: none;
5693 }
5694
5695 .mat-tab-group, .mat-tab-nav-bar {
5696 $theme-colors: (
5697 primary: $primary,
5698 accent: $accent,
5699 warn: $warn
5700 );
5701
5702 @each $name, $color in $theme-colors {
5703 // Set the foreground color of the tabs
5704 &.mat-#{$name} {
5705 @include _mat-tab-label-focus($color);
5706 @include _mat-ink-bar($color);
5707
5708 // Override ink bar when background color is the same
5709 &.mat-background-#{$name} {
5710 > .mat-tab-header, > .mat-tab-link-container {
5711 @include _mat-ink-bar($color, default-contrast);
5712 }
5713 }
5714 }
5715 }
5716
5717 @each $name, $color in $theme-colors {
5718 // Set background color of the tabs and override focus color
5719 &.mat-background-#{$name} {
5720 @include _mat-tab-label-focus($color);
5721 @include _mat-tabs-background($color);
5722 }
5723 }
5724 }
5725}
5726
5727@mixin _mat-ink-bar($color, $hue: default) {
5728 .mat-ink-bar {
5729 background-color: mat-color($color, $hue);
5730 }
5731}
5732
5733@mixin _mat-tab-label-focus($tab-focus-color) {
5734 .mat-tab-label,
5735 .mat-tab-link {
5736 &.cdk-keyboard-focused,
5737 &.cdk-program-focused {
5738 &:not(.mat-tab-disabled) {
5739 background-color: mat-color($tab-focus-color, lighter, 0.3);
5740 }
5741 }
5742 }
5743}
5744
5745@mixin _mat-tabs-background($background-color) {
5746 // Note that these selectors target direct descendants so
5747 // that the styles don't apply to any nested tab groups.
5748
5749 // Set background color for the tab group
5750 > .mat-tab-header, > .mat-tab-link-container, > .mat-tab-header-pagination {
5751 background-color: mat-color($background-color);
5752 }
5753
5754 // Set labels to contrast against background
5755 > .mat-tab-header .mat-tab-label, > .mat-tab-link-container .mat-tab-link {
5756 color: mat-color($background-color, default-contrast);
5757
5758 &.mat-tab-disabled {
5759 color: mat-color($background-color, default-contrast, 0.4);
5760 }
5761 }
5762
5763 // Set pagination chevrons to contrast background
5764 > .mat-tab-header-pagination .mat-tab-header-pagination-chevron,
5765 > .mat-tab-links .mat-focus-indicator::before,
5766 > .mat-tab-header .mat-focus-indicator::before {
5767 border-color: mat-color($background-color, default-contrast);
5768 }
5769
5770 > .mat-tab-header-pagination-disabled .mat-tab-header-pagination-chevron {
5771 border-color: mat-color($background-color, default-contrast, 0.4);
5772 }
5773
5774 // Set ripples color to be the contrast color of the new background. Otherwise the ripple
5775 // color will be based on the app background color.
5776 > .mat-tab-header .mat-ripple-element,
5777 > .mat-tab-link-container .mat-ripple-element {
5778 background-color: mat-color($background-color, default-contrast, 0.12);
5779 }
5780}
5781
5782@mixin mat-tabs-typography($config-or-theme) {
5783 $config: mat-get-typography-config($config-or-theme);
5784 .mat-tab-group {
5785 font-family: mat-font-family($config);
5786 }
5787
5788 .mat-tab-label, .mat-tab-link {
5789 font: {
5790 family: mat-font-family($config, button);
5791 size: mat-font-size($config, button);
5792 weight: mat-font-weight($config, button);
5793 }
5794 }
5795}
5796
5797@mixin _mat-tabs-density($config-or-theme) {}
5798
5799@mixin mat-tabs-theme($theme-or-color-config) {
5800 $theme: mat-private-legacy-get-theme($theme-or-color-config);
5801 @include mat-private-check-duplicate-theme-styles($theme, 'mat-tabs') {
5802 $color: mat-get-color-config($theme);
5803 $density: mat-get-density-config($theme);
5804 $typography: mat-get-typography-config($theme);
5805
5806 @if $color != null {
5807 @include mat-tabs-color($color);
5808 }
5809 @if $density != null {
5810 @include _mat-tabs-density($density);
5811 }
5812 @if $typography != null {
5813 @include mat-tabs-typography($typography);
5814 }
5815 }
5816}
5817
5818
5819
5820
5821
5822
5823// Minimum height for toolbar's in the highest density is difficult to determine because
5824// developers can project arbitrary content. We use a minimum value that ensures that most
5825// common content (e.g. icon buttons) does not exceed the row boundaries in highest density.
5826$mat-toolbar-minimum-height: 44px !default;
5827
5828$mat-toolbar-height-desktop: 64px !default;
5829$mat-toolbar-maximum-height-desktop: $mat-toolbar-height-desktop !default;
5830$mat-toolbar-minimum-height-desktop: $mat-toolbar-minimum-height !default;
5831
5832$mat-toolbar-height-mobile: 56px !default;
5833$mat-toolbar-maximum-height-mobile: $mat-toolbar-height-mobile !default;
5834$mat-toolbar-minimum-height-mobile: $mat-toolbar-minimum-height !default;
5835
5836$mat-toolbar-desktop-density-config: (
5837 height: (
5838 default: $mat-toolbar-height-desktop,
5839 maximum: $mat-toolbar-maximum-height-desktop,
5840 minimum: $mat-toolbar-minimum-height-desktop,
5841 )
5842) !default;
5843
5844$mat-toolbar-mobile-density-config: (
5845 height: (
5846 default: $mat-toolbar-height-mobile,
5847 maximum: $mat-toolbar-maximum-height-mobile,
5848 minimum: $mat-toolbar-minimum-height-mobile,
5849 )
5850) !default;
5851
5852
5853@mixin _mat-toolbar-height($height) {
5854 .mat-toolbar-multiple-rows {
5855 min-height: $height;
5856 }
5857 .mat-toolbar-row, .mat-toolbar-single-row {
5858 height: $height;
5859 }
5860}
5861
5862@mixin _mat-toolbar-color($palette) {
5863 background: mat-color($palette);
5864 color: mat-color($palette, default-contrast);
5865}
5866
5867@mixin _mat-toolbar-form-field-overrides {
5868 .mat-form-field-underline,
5869 .mat-form-field-ripple,
5870 .mat-focused .mat-form-field-ripple {
5871 background-color: currentColor;
5872 }
5873
5874 .mat-form-field-label,
5875 .mat-focused .mat-form-field-label,
5876 .mat-select-value,
5877 .mat-select-arrow,
5878 .mat-form-field.mat-focused .mat-select-arrow {
5879 color: inherit;
5880 }
5881
5882 .mat-input-element {
5883 caret-color: currentColor;
5884 }
5885}
5886
5887@mixin mat-toolbar-color($config-or-theme) {
5888 $config: mat-get-color-config($config-or-theme);
5889 $primary: map-get($config, primary);
5890 $accent: map-get($config, accent);
5891 $warn: map-get($config, warn);
5892 $background: map-get($config, background);
5893 $foreground: map-get($config, foreground);
5894
5895 .mat-toolbar {
5896 background: mat-color($background, app-bar);
5897 color: mat-color($foreground, text);
5898
5899 &.mat-primary {
5900 @include _mat-toolbar-color($primary);
5901 }
5902
5903 &.mat-accent {
5904 @include _mat-toolbar-color($accent);
5905 }
5906
5907 &.mat-warn {
5908 @include _mat-toolbar-color($warn);
5909 }
5910
5911 @include _mat-toolbar-form-field-overrides;
5912 }
5913}
5914
5915@mixin mat-toolbar-typography($config-or-theme) {
5916 $config: mat-get-typography-config($config-or-theme);
5917 .mat-toolbar,
5918 .mat-toolbar h1,
5919 .mat-toolbar h2,
5920 .mat-toolbar h3,
5921 .mat-toolbar h4,
5922 .mat-toolbar h5,
5923 .mat-toolbar h6 {
5924 @include mat-typography-level-to-styles($config, title);
5925 margin: 0;
5926 }
5927}
5928
5929@mixin mat-toolbar-density($config-or-theme) {
5930 $density-scale: mat-get-density-config($config-or-theme);
5931 $height-desktop: mat-private-density-prop-value(
5932 $mat-toolbar-desktop-density-config, $density-scale, height);
5933 $height-mobile: mat-private-density-prop-value(
5934 $mat-toolbar-mobile-density-config, $density-scale, height);
5935
5936 @include mat-private-density-legacy-compatibility() {
5937 // Set the default height for the toolbar.
5938 @include _mat-toolbar-height($height-desktop);
5939
5940 // As per specs, toolbars should have a different height in mobile devices. This has been
5941 // specified in the old guidelines and is still observable in the new specifications by
5942 // looking at the spec images. See: https://material.io/design/components/app-bars-top.html#anatomy
5943 @media ($mat-xsmall) {
5944 @include _mat-toolbar-height($height-mobile);
5945 }
5946 }
5947}
5948
5949@mixin mat-toolbar-theme($theme-or-color-config) {
5950 $theme: mat-private-legacy-get-theme($theme-or-color-config);
5951 @include mat-private-check-duplicate-theme-styles($theme, 'mat-toolbar') {
5952 $color: mat-get-color-config($theme);
5953 $density: mat-get-density-config($theme);
5954 $typography: mat-get-typography-config($theme);
5955
5956 @if $color != null {
5957 @include mat-toolbar-color($color);
5958 }
5959 @if $density != null {
5960 @include mat-toolbar-density($density);
5961 }
5962 @if $typography != null {
5963 @include mat-toolbar-typography($typography);
5964 }
5965 }
5966}
5967
5968
5969
5970
5971
5972$mat-tooltip-target-height: 22px;
5973$mat-tooltip-font-size: 10px;
5974$mat-tooltip-vertical-padding: ($mat-tooltip-target-height - $mat-tooltip-font-size) / 2;
5975
5976$mat-tooltip-handset-target-height: 30px;
5977$mat-tooltip-handset-font-size: 14px;
5978$mat-tooltip-handset-vertical-padding:
5979 ($mat-tooltip-handset-target-height - $mat-tooltip-handset-font-size) / 2;
5980
5981@mixin mat-tooltip-color($config-or-theme) {
5982 $config: mat-get-color-config($config-or-theme);
5983 $background: map-get($config, background);
5984
5985 .mat-tooltip {
5986 background: mat-color($background, tooltip, 0.9);
5987 }
5988}
5989
5990@mixin mat-tooltip-typography($config-or-theme) {
5991 $config: mat-get-typography-config($config-or-theme);
5992 .mat-tooltip {
5993 font-family: mat-font-family($config);
5994 font-size: $mat-tooltip-font-size;
5995 padding-top: $mat-tooltip-vertical-padding;
5996 padding-bottom: $mat-tooltip-vertical-padding;
5997 }
5998
5999 .mat-tooltip-handset {
6000 font-size: $mat-tooltip-handset-font-size;
6001 padding-top: $mat-tooltip-handset-vertical-padding;
6002 padding-bottom: $mat-tooltip-handset-vertical-padding;
6003 }
6004}
6005
6006@mixin _mat-tooltip-density($config-or-theme) {}
6007
6008@mixin mat-tooltip-theme($theme-or-color-config) {
6009 $theme: mat-private-legacy-get-theme($theme-or-color-config);
6010 @include mat-private-check-duplicate-theme-styles($theme, 'mat-tooltip') {
6011 $color: mat-get-color-config($theme);
6012 $density: mat-get-density-config($theme);
6013 $typography: mat-get-typography-config($theme);
6014
6015 @if $color != null {
6016 @include mat-tooltip-color($color);
6017 }
6018 @if $density != null {
6019 @include _mat-tooltip-density($density);
6020 }
6021 @if $typography != null {
6022 @include mat-tooltip-typography($typography);
6023 }
6024 }
6025}
6026
6027
6028
6029
6030
6031
6032
6033@mixin mat-snack-bar-color($config-or-theme) {
6034 $config: mat-get-color-config($config-or-theme);
6035 $is-dark-theme: map-get($config, is-dark);
6036 $accent: map-get($config, accent);
6037
6038 .mat-snack-bar-container {
6039 // Use the primary text on the dark theme, even though the lighter one uses
6040 // a secondary, because the contrast on the light primary text is poor.
6041 color: if($is-dark-theme, $dark-primary-text, $light-secondary-text);
6042 background: if($is-dark-theme, map-get($mat-grey, 50), #323232);
6043
6044 @include mat-private-theme-elevation(6, $config);
6045 }
6046
6047 .mat-simple-snackbar-action {
6048 color: if($is-dark-theme, inherit, mat-color($accent, text));
6049 }
6050}
6051
6052@mixin mat-snack-bar-typography($config-or-theme) {
6053 $config: mat-get-typography-config($config-or-theme);
6054 .mat-simple-snackbar {
6055 font: {
6056 family: mat-font-family($config, body-1);
6057 size: mat-font-size($config, body-1);
6058 }
6059 }
6060
6061 .mat-simple-snackbar-action {
6062 line-height: 1;
6063 font: {
6064 family: inherit;
6065 size: inherit;
6066 weight: mat-font-weight($config, button);
6067 }
6068 }
6069}
6070
6071@mixin _mat-snack-bar-density($config-or-theme) {}
6072
6073@mixin mat-snack-bar-theme($theme-or-color-config) {
6074 $theme: mat-private-legacy-get-theme($theme-or-color-config);
6075 @include mat-private-check-duplicate-theme-styles($theme, 'mat-snack-bar') {
6076 $color: mat-get-color-config($theme);
6077 $density: mat-get-density-config($theme);
6078 $typography: mat-get-typography-config($theme);
6079
6080 @if $color != null {
6081 @include mat-snack-bar-color($color);
6082 }
6083 @if $density != null {
6084 @include _mat-snack-bar-density($density);
6085 }
6086 @if $typography != null {
6087 @include mat-snack-bar-typography($typography);
6088 }
6089 }
6090}
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105// Theme styles that only apply to the fill appearance of the form-field.
6106
6107@mixin mat-form-field-fill-color($config-or-theme) {
6108 $config: mat-get-color-config($config-or-theme);
6109 $foreground: map-get($config, foreground);
6110 $is-dark-theme: map-get($config, is-dark);
6111
6112 $fill-background: mat-color($foreground, base, if($is-dark-theme, 0.1, 0.04));
6113 $fill-disabled-background: mat-color($foreground, base, if($is-dark-theme, 0.05, 0.02));
6114 $underline-color: mat-color($foreground, divider, if($is-dark-theme, 0.5, 0.42));
6115 $label-disabled-color: mat-color($foreground, disabled-text);
6116
6117 .mat-form-field-appearance-fill {
6118 .mat-form-field-flex {
6119 background-color: $fill-background;
6120 }
6121
6122 &.mat-form-field-disabled .mat-form-field-flex {
6123 background-color: $fill-disabled-background;
6124 }
6125
6126 .mat-form-field-underline::before {
6127 background-color: $underline-color;
6128 }
6129
6130 &.mat-form-field-disabled {
6131 .mat-form-field-label {
6132 color: $label-disabled-color;
6133 }
6134
6135 .mat-form-field-underline::before {
6136 background-color: transparent;
6137 }
6138 }
6139 }
6140}
6141
6142// Used to make instances of the _mat-form-field-label-floating mixin negligibly different,
6143// and prevent Google's CSS Optimizer from collapsing the declarations. This is needed because some
6144// of the selectors contain pseudo-classes not recognized in all browsers. If a browser encounters
6145// an unknown pseudo-class it will discard the entire rule set.
6146$mat-form-field-fill-dedupe: 0;
6147
6148// Applies a floating label above the form field control itself.
6149@mixin _mat-form-field-fill-label-floating($font-scale, $infix-padding, $infix-margin-top) {
6150 transform: translateY(-$infix-margin-top - $infix-padding + $mat-form-field-fill-dedupe)
6151 scale($font-scale);
6152 width: 100% / $font-scale + $mat-form-field-fill-dedupe;
6153
6154 $mat-form-field-fill-dedupe: $mat-form-field-fill-dedupe + 0.00001 !global;
6155}
6156
6157@mixin mat-form-field-fill-typography($config-or-theme) {
6158 $config: mat-get-typography-config($config-or-theme);
6159 // The unit-less line-height from the font config.
6160 $line-height: mat-line-height($config, input);
6161 // The amount to scale the font for the floating label and subscript.
6162 $subscript-font-scale: 0.75;
6163 // The padding on top of the infix.
6164 $infix-padding-top: 0.25em;
6165 // The padding below the infix.
6166 $infix-padding-bottom: 0.75em;
6167 // The margin applied to the form-field-infix to reserve space for the floating label.
6168 $infix-margin-top: 1em * $line-height * $subscript-font-scale;
6169 // The amount we offset the label from the input text in the fill appearance.
6170 $fill-appearance-label-offset: -0.5em;
6171
6172 .mat-form-field-appearance-fill {
6173 .mat-form-field-infix {
6174 padding: $infix-padding-top 0 $infix-padding-bottom 0;
6175 }
6176
6177 .mat-form-field-label {
6178 top: $infix-margin-top + $infix-padding-top;
6179 margin-top: $fill-appearance-label-offset;
6180 }
6181
6182 &.mat-form-field-can-float {
6183 &.mat-form-field-should-float .mat-form-field-label,
6184 .mat-input-server:focus + .mat-form-field-label-wrapper .mat-form-field-label {
6185 @include _mat-form-field-fill-label-floating(
6186 $subscript-font-scale, $infix-padding-top + $fill-appearance-label-offset,
6187 $infix-margin-top);
6188 }
6189
6190 // Server-side rendered matInput with a label attribute but label not shown
6191 // (used as a pure CSS stand-in for mat-form-field-should-float).
6192 .mat-input-server[label]:not(:label-shown) + .mat-form-field-label-wrapper
6193 .mat-form-field-label {
6194 @include _mat-form-field-fill-label-floating(
6195 $subscript-font-scale, $infix-padding-top + $fill-appearance-label-offset,
6196 $infix-margin-top);
6197 }
6198 }
6199 }
6200}
6201
6202@mixin mat-private-form-field-fill-density($config-or-theme) {}
6203
6204@mixin mat-form-field-fill-theme($theme-or-color-config) {
6205 $theme: mat-private-legacy-get-theme($theme-or-color-config);
6206 @include mat-private-check-duplicate-theme-styles($theme, 'mat-form-field-fill') {
6207 $color: mat-get-color-config($theme);
6208 $density: mat-get-density-config($theme);
6209 $typography: mat-get-typography-config($theme);
6210
6211 @if $color != null {
6212 @include mat-form-field-fill-color($color);
6213 }
6214 @if $density != null {
6215 @include mat-private-form-field-fill-density($density);
6216 }
6217 @if $typography != null {
6218 @include mat-form-field-fill-typography($typography);
6219 }
6220 }
6221}
6222
6223
6224
6225
6226
6227
6228
6229// Theme styles that only apply to the legacy appearance of the form-field.
6230
6231@mixin mat-form-field-legacy-color($config-or-theme) {
6232 $config: mat-get-color-config($config-or-theme);
6233 $foreground: map-get($config, foreground);
6234 $is-dark-theme: map-get($config, is-dark);
6235
6236 $label-color: mat-color($foreground, secondary-text);
6237 $underline-color: mat-color($foreground, divider, if($is-dark-theme, 0.7, 0.42));
6238
6239 .mat-form-field-appearance-legacy {
6240 .mat-form-field-label {
6241 color: $label-color;
6242 }
6243
6244 .mat-hint {
6245 color: $label-color;
6246 }
6247
6248 .mat-form-field-underline {
6249 background-color: $underline-color;
6250 }
6251
6252 &.mat-form-field-disabled .mat-form-field-underline {
6253 @include mat-private-control-disabled-underline($underline-color);
6254 }
6255 }
6256}
6257
6258// Used to make instances of the _mat-form-field-label-floating mixin negligibly different,
6259// and prevent Google's CSS Optimizer from collapsing the declarations. This is needed because some
6260// of the selectors contain pseudo-classes not recognized in all browsers. If a browser encounters
6261// an unknown pseudo-class it will discard the entire rule set.
6262$mat-form-field-legacy-dedupe: 0;
6263
6264// Applies a floating label above the form field control itself.
6265@mixin _mat-form-field-legacy-label-floating($font-scale, $infix-padding, $infix-margin-top) {
6266 // We use perspective to fix the text blurriness as described here:
6267 // http://www.useragentman.com/blog/2014/05/04/fixing-typography-inside-of-2-d-css-transforms/
6268 // This results in a small jitter after the label floats on Firefox, which the
6269 // translateZ fixes.
6270 transform: translateY(-$infix-margin-top - $infix-padding) scale($font-scale) perspective(100px)
6271 translateZ(0.001px + $mat-form-field-legacy-dedupe);
6272 // The tricks above used to smooth out the animation on chrome and firefox actually make things
6273 // worse on IE, so we don't include them in the IE version.
6274 -ms-transform: translateY(-$infix-margin-top - $infix-padding + $mat-form-field-legacy-dedupe)
6275 scale($font-scale);
6276
6277 width: 100% / $font-scale + $mat-form-field-legacy-dedupe;
6278
6279 $mat-form-field-legacy-dedupe: $mat-form-field-legacy-dedupe + 0.00001 !global;
6280}
6281
6282// Same as mixin above, but omits the translateZ for printing purposes.
6283@mixin _mat-form-field-legacy-label-floating-print($font-scale, $infix-padding, $infix-margin-top) {
6284 // This results in a small jitter after the label floats on Firefox, which the
6285 // translateZ fixes.
6286 transform: translateY(-$infix-margin-top - $infix-padding + $mat-form-field-legacy-dedupe)
6287 scale($font-scale);
6288 // The tricks above used to smooth out the animation on chrome and firefox actually make things
6289 // worse on IE, so we don't include them in the IE version.
6290 $mat-form-field-legacy-dedupe: $mat-form-field-legacy-dedupe + 0.00001 !global;
6291}
6292
6293@mixin mat-form-field-legacy-typography($config-or-theme) {
6294 $config: mat-get-typography-config($config-or-theme);
6295 // The unit-less line-height from the font config.
6296 $line-height: mat-line-height($config, input);
6297 // The amount to scale the font for the floating label and subscript.
6298 $subscript-font-scale: 0.75;
6299 // The amount of space between the top of the line and the top of the actual text
6300 // (as a fraction of the font-size).
6301 $line-spacing: ($line-height - 1) / 2;
6302 // The padding on the infix. Mocks show half of the text size, but seem to measure from the edge
6303 // of the text itself, not the edge of the line; therefore we subtract off the line spacing.
6304 $infix-padding: 0.5em - $line-spacing;
6305 // The margin applied to the form-field-infix to reserve space for the floating label.
6306 $infix-margin-top: 1em * $line-height * $subscript-font-scale;
6307 // The space between the bottom of the .mat-form-field-flex area and the subscript wrapper.
6308 // Mocks show half of the text size, but this margin is applied to an element with the subscript
6309 // text font size, so we need to divide by the scale factor to make it half of the original text
6310 // size. We again need to subtract off the line spacing since the mocks measure to the edge of the
6311 // text, not the edge of the line.
6312 $subscript-margin-top: 0.5em / $subscript-font-scale - ($line-spacing * 2);
6313 // The padding applied to the form-field-wrapper to reserve space for the subscript, since it's
6314 // absolutely positioned. This is a combination of the subscript's margin and line-height, but we
6315 // need to multiply by the subscript font scale factor since the wrapper has a larger font size.
6316 $wrapper-padding-bottom: ($subscript-margin-top + $line-height) * $subscript-font-scale;
6317
6318 .mat-form-field-appearance-legacy {
6319 .mat-form-field-wrapper {
6320 padding-bottom: $wrapper-padding-bottom;
6321 }
6322
6323 .mat-form-field-infix {
6324 padding: $infix-padding 0;
6325 }
6326
6327 &.mat-form-field-can-float {
6328 &.mat-form-field-should-float .mat-form-field-label,
6329 .mat-input-server:focus + .mat-form-field-label-wrapper .mat-form-field-label {
6330 @include _mat-form-field-legacy-label-floating(
6331 $subscript-font-scale, $infix-padding, $infix-margin-top);
6332 }
6333
6334 // @breaking-change 8.0.0 will rely on AutofillMonitor instead.
6335 .mat-form-field-autofill-control:-webkit-autofill + .mat-form-field-label-wrapper
6336 .mat-form-field-label {
6337 @include _mat-form-field-legacy-label-floating(
6338 $subscript-font-scale, $infix-padding, $infix-margin-top);
6339 }
6340
6341 // Server-side rendered matInput with a label attribute but label not shown
6342 // (used as a pure CSS stand-in for mat-form-field-should-float).
6343 .mat-input-server[label]:not(:label-shown) + .mat-form-field-label-wrapper
6344 .mat-form-field-label {
6345 @include _mat-form-field-legacy-label-floating(
6346 $subscript-font-scale, $infix-padding, $infix-margin-top);
6347 }
6348 }
6349
6350 .mat-form-field-label {
6351 top: $infix-margin-top + $infix-padding;
6352 }
6353
6354 .mat-form-field-underline {
6355 // We want the underline to start at the end of the content box, not the padding box,
6356 // so we move it up by the padding amount.
6357 bottom: $wrapper-padding-bottom;
6358 }
6359
6360 .mat-form-field-subscript-wrapper {
6361 margin-top: $subscript-margin-top;
6362
6363 // We want the subscript to start at the end of the content box, not the padding box,
6364 // so we move it up by the padding amount (adjusted for the smaller font size);
6365 top: calc(100% - #{$wrapper-padding-bottom / $subscript-font-scale});
6366 }
6367 }
6368
6369 // translateZ causes the label to not appear while printing, so we override it to not
6370 // apply translateZ while printing
6371 @media print {
6372 .mat-form-field-appearance-legacy {
6373 &.mat-form-field-can-float {
6374 &.mat-form-field-should-float .mat-form-field-label,
6375 .mat-input-server:focus + .mat-form-field-label-wrapper .mat-form-field-label {
6376 @include _mat-form-field-legacy-label-floating-print(
6377 $subscript-font-scale, $infix-padding, $infix-margin-top);
6378 }
6379
6380 // @breaking-change 8.0.0 will rely on AutofillMonitor instead.
6381 .mat-form-field-autofill-control:-webkit-autofill + .mat-form-field-label-wrapper
6382 .mat-form-field-label {
6383 @include _mat-form-field-legacy-label-floating-print(
6384 $subscript-font-scale, $infix-padding, $infix-margin-top);
6385 }
6386
6387 // Server-side rendered matInput with a label attribute but label not shown
6388 // (used as a pure CSS stand-in for mat-form-field-should-float).
6389 .mat-input-server[label]:not(:label-shown) + .mat-form-field-label-wrapper
6390 .mat-form-field-label {
6391 @include _mat-form-field-legacy-label-floating-print(
6392 $subscript-font-scale, $infix-padding, $infix-margin-top);
6393 }
6394 }
6395 }
6396 }
6397}
6398
6399@mixin mat-private-form-field-legacy-density($config-or-theme) {}
6400
6401@mixin mat-form-field-legacy-theme($theme-or-color-config) {
6402 $theme: mat-private-legacy-get-theme($theme-or-color-config);
6403 @include mat-private-check-duplicate-theme-styles($theme, 'mat-form-field-legacy') {
6404 $color: mat-get-color-config($theme);
6405 $density: mat-get-density-config($theme);
6406 $typography: mat-get-typography-config($theme);
6407
6408 @if $color != null {
6409 @include mat-form-field-legacy-color($color);
6410 }
6411 @if $density != null {
6412 @include mat-private-form-field-legacy-density($density);
6413 }
6414 @if $typography != null {
6415 @include mat-form-field-legacy-typography($typography);
6416 }
6417 }
6418}
6419
6420
6421
6422
6423
6424
6425
6426// Theme styles that only apply to the outline appearance of the form-field.
6427
6428@mixin mat-form-field-outline-color($config-or-theme) {
6429 $config: mat-get-color-config($config-or-theme);
6430 $primary: map-get($config, primary);
6431 $accent: map-get($config, accent);
6432 $warn: map-get($config, warn);
6433 $foreground: map-get($config, foreground);
6434 $is-dark-theme: map-get($config, is-dark);
6435
6436 $label-disabled-color: mat-color($foreground, disabled-text);
6437 $outline-color: mat-color($foreground, divider, if($is-dark-theme, 0.3, 0.12));
6438 $outline-color-hover: mat-color($foreground, divider, if($is-dark-theme, 1, 0.87));
6439 $outline-color-primary: mat-color($primary);
6440 $outline-color-accent: mat-color($accent);
6441 $outline-color-warn: mat-color($warn);
6442 $outline-color-disabled: mat-color($foreground, divider, if($is-dark-theme, 0.15, 0.06));
6443
6444 .mat-form-field-appearance-outline {
6445 .mat-form-field-outline {
6446 color: $outline-color;
6447 }
6448
6449 .mat-form-field-outline-thick {
6450 color: $outline-color-hover;
6451 }
6452
6453 &.mat-focused {
6454 .mat-form-field-outline-thick {
6455 color: $outline-color-primary;
6456 }
6457
6458 &.mat-accent .mat-form-field-outline-thick {
6459 color: $outline-color-accent;
6460 }
6461
6462 &.mat-warn .mat-form-field-outline-thick {
6463 color: $outline-color-warn;
6464 }
6465 }
6466
6467 // Class repeated so that rule is specific enough to override focused accent color case.
6468 &.mat-form-field-invalid.mat-form-field-invalid {
6469 .mat-form-field-outline-thick {
6470 color: $outline-color-warn;
6471 }
6472 }
6473
6474 &.mat-form-field-disabled {
6475 .mat-form-field-label {
6476 color: $label-disabled-color;
6477 }
6478
6479 .mat-form-field-outline {
6480 color: $outline-color-disabled;
6481 }
6482 }
6483 }
6484}
6485
6486// Used to make instances of the _mat-form-field-label-floating mixin negligibly different,
6487// and prevent Google's CSS Optimizer from collapsing the declarations. This is needed because some
6488// of the selectors contain pseudo-classes not recognized in all browsers. If a browser encounters
6489// an unknown pseudo-class it will discard the entire rule set.
6490$mat-form-field-outline-dedupe: 0;
6491
6492// Applies a floating label above the form field control itself.
6493@mixin _mat-form-field-outline-label-floating($font-scale, $infix-padding, $infix-margin-top) {
6494 transform: translateY(-$infix-margin-top - $infix-padding + $mat-form-field-outline-dedupe)
6495 scale($font-scale);
6496 width: 100% / $font-scale + $mat-form-field-outline-dedupe;
6497
6498 $mat-form-field-outline-dedupe: $mat-form-field-outline-dedupe + 0.00001 !global;
6499}
6500
6501@mixin mat-form-field-outline-typography($config-or-theme) {
6502 $config: mat-get-typography-config($config-or-theme);
6503 // The unit-less line-height from the font config.
6504 $line-height: mat-line-height($config, input);
6505 // The amount to scale the font for the floating label and subscript.
6506 $subscript-font-scale: 0.75;
6507 // The padding above and below the infix.
6508 $infix-padding: 1em;
6509 // The margin applied to the form-field-infix to reserve space for the floating label.
6510 $infix-margin-top: 1em * $line-height * $subscript-font-scale;
6511 // The space between the bottom of the .mat-form-field-flex area and the subscript wrapper.
6512 // Mocks show half of the text size, but this margin is applied to an element with the subscript
6513 // text font size, so we need to divide by the scale factor to make it half of the original text
6514 // size.
6515 $subscript-margin-top: 0.5em / $subscript-font-scale;
6516 // The padding applied to the form-field-wrapper to reserve space for the subscript, since it's
6517 // absolutely positioned. This is a combination of the subscript's margin and line-height, but we
6518 // need to multiply by the subscript font scale factor since the wrapper has a larger font size.
6519 $wrapper-padding-bottom: ($subscript-margin-top + $line-height) * $subscript-font-scale;
6520 // The amount we offset the label from the input text in the outline appearance.
6521 $outline-appearance-label-offset: -0.25em;
6522
6523 .mat-form-field-appearance-outline {
6524 .mat-form-field-infix {
6525 padding: $infix-padding 0 $infix-padding 0;
6526 }
6527
6528 .mat-form-field-label {
6529 top: $infix-margin-top + $infix-padding;
6530 margin-top: $outline-appearance-label-offset;
6531 }
6532
6533 &.mat-form-field-can-float {
6534 &.mat-form-field-should-float .mat-form-field-label,
6535 .mat-input-server:focus + .mat-form-field-label-wrapper .mat-form-field-label {
6536 @include _mat-form-field-outline-label-floating(
6537 $subscript-font-scale, $infix-padding + $outline-appearance-label-offset,
6538 $infix-margin-top);
6539 }
6540
6541 // Server-side rendered matInput with a label attribute but label not shown
6542 // (used as a pure CSS stand-in for mat-form-field-should-float).
6543 .mat-input-server[label]:not(:label-shown) + .mat-form-field-label-wrapper
6544 .mat-form-field-label {
6545 @include _mat-form-field-outline-label-floating(
6546 $subscript-font-scale, $infix-padding + $outline-appearance-label-offset,
6547 $infix-margin-top);
6548 }
6549 }
6550 }
6551}
6552
6553@mixin mat-private-form-field-outline-density($config-or-theme) {}
6554
6555@mixin mat-form-field-outline-theme($theme-or-color-config) {
6556 $theme: mat-private-legacy-get-theme($theme-or-color-config);
6557 @include mat-private-check-duplicate-theme-styles($theme, 'mat-form-field-outline') {
6558 $color: mat-get-color-config($theme);
6559 $density: mat-get-density-config($theme);
6560 $typography: mat-get-typography-config($theme);
6561
6562 @if $color != null {
6563 @include mat-form-field-outline-color($color);
6564 }
6565 @if $density != null {
6566 @include mat-private-form-field-outline-density($density);
6567 }
6568 @if $typography != null {
6569 @include mat-form-field-outline-typography($typography);
6570 }
6571 }
6572}
6573
6574
6575
6576
6577
6578
6579
6580
6581// Theme styles that only apply to the standard appearance of the form-field.
6582
6583@mixin mat-form-field-standard-color($config-or-theme) {
6584 $config: mat-get-color-config($config-or-theme);
6585 $foreground: map-get($config, foreground);
6586 $is-dark-theme: map-get($config, is-dark);
6587
6588 $underline-color: mat-color($foreground, divider, if($is-dark-theme, 0.7, 0.42));
6589
6590 .mat-form-field-appearance-standard {
6591 .mat-form-field-underline {
6592 background-color: $underline-color;
6593 }
6594
6595 &.mat-form-field-disabled .mat-form-field-underline {
6596 @include mat-private-control-disabled-underline($underline-color);
6597 }
6598 }
6599}
6600
6601@mixin mat-form-field-standard-typography($config-or-theme) {}
6602
6603@mixin mat-private-form-field-standard-density($config-or-theme) {}
6604
6605@mixin mat-form-field-standard-theme($theme-or-color-config) {
6606 $theme: mat-private-legacy-get-theme($theme-or-color-config);
6607 @include mat-private-check-duplicate-theme-styles($theme, 'mat-form-field-standard') {
6608 $color: mat-get-color-config($theme);
6609 $density: mat-get-density-config($theme);
6610 $typography: mat-get-typography-config($theme);
6611
6612 @if $color != null {
6613 @include mat-form-field-standard-color($color);
6614 }
6615 @if $density != null {
6616 @include mat-private-form-field-standard-density($density);
6617 }
6618 @if $typography != null {
6619 @include mat-form-field-standard-typography($typography);
6620 }
6621 }
6622}
6623
6624
6625// Color styles that apply to all appearances of the form-field.
6626@mixin mat-form-field-color($config-or-theme) {
6627 $config: mat-get-color-config($config-or-theme);
6628 $primary: map-get($config, primary);
6629 $accent: map-get($config, accent);
6630 $warn: map-get($config, warn);
6631 $background: map-get($config, background);
6632 $foreground: map-get($config, foreground);
6633 $is-dark-theme: map-get($config, is-dark);
6634
6635 // Label colors. Required is used for the `*` star shown in the label.
6636 $label-color: mat-color($foreground, secondary-text, if($is-dark-theme, 0.7, 0.6));
6637 $focused-label-color: mat-color($primary, text);
6638 $required-label-color: mat-color($accent, text);
6639
6640 // Underline colors.
6641 $underline-color-base: mat-color($foreground, divider, if($is-dark-theme, 1, 0.87));
6642 $underline-color-accent: mat-color($accent, text);
6643 $underline-color-warn: mat-color($warn, text);
6644 $underline-focused-color: mat-color($primary, text);
6645
6646 .mat-form-field-label {
6647 color: $label-color;
6648 }
6649
6650 .mat-hint {
6651 color: $label-color;
6652 }
6653
6654 .mat-form-field.mat-focused .mat-form-field-label {
6655 color: $focused-label-color;
6656
6657 &.mat-accent {
6658 color: $underline-color-accent;
6659 }
6660
6661 &.mat-warn {
6662 color: $underline-color-warn;
6663 }
6664 }
6665
6666 .mat-focused .mat-form-field-required-marker {
6667 color: $required-label-color;
6668 }
6669
6670 .mat-form-field-ripple {
6671 background-color: $underline-color-base;
6672 }
6673
6674 .mat-form-field.mat-focused {
6675 .mat-form-field-ripple {
6676 background-color: $underline-focused-color;
6677
6678 &.mat-accent {
6679 background-color: $underline-color-accent;
6680 }
6681
6682 &.mat-warn {
6683 background-color: $underline-color-warn;
6684 }
6685 }
6686 }
6687
6688 .mat-form-field-type-mat-native-select.mat-focused:not(.mat-form-field-invalid) {
6689 .mat-form-field-infix::after {
6690 color: $underline-focused-color;
6691 }
6692
6693 &.mat-accent .mat-form-field-infix::after {
6694 color: $underline-color-accent;
6695 }
6696
6697 &.mat-warn .mat-form-field-infix::after {
6698 color: $underline-color-warn;
6699 }
6700 }
6701
6702 // Styling for the error state of the form field. Note that while the same can be
6703 // achieved with the ng-* classes, we use this approach in order to ensure that the same
6704 // logic is used to style the error state and to show the error messages.
6705 .mat-form-field.mat-form-field-invalid {
6706 .mat-form-field-label {
6707 color: $underline-color-warn;
6708
6709 &.mat-accent,
6710 .mat-form-field-required-marker {
6711 color: $underline-color-warn;
6712 }
6713 }
6714
6715 .mat-form-field-ripple,
6716 .mat-form-field-ripple.mat-accent {
6717 background-color: $underline-color-warn;
6718 }
6719 }
6720
6721 .mat-error {
6722 color: $underline-color-warn;
6723 }
6724
6725 @include mat-form-field-legacy-color($config);
6726 @include mat-form-field-standard-color($config);
6727 @include mat-form-field-fill-color($config);
6728 @include mat-form-field-outline-color($config);
6729}
6730
6731// Used to make instances of the _mat-form-field-label-floating mixin negligibly different,
6732// and prevent Google's CSS Optimizer from collapsing the declarations. This is needed because some
6733// of the selectors contain pseudo-classes not recognized in all browsers. If a browser encounters
6734// an unknown pseudo-class it will discard the entire rule set.
6735$mat-form-field-dedupe: 0;
6736
6737// Applies a floating label above the form field control itself.
6738@mixin _mat-form-field-label-floating($font-scale, $infix-padding, $infix-margin-top) {
6739 transform: translateY(-$infix-margin-top - $infix-padding + $mat-form-field-dedupe)
6740 scale($font-scale);
6741 width: 100% / $font-scale + $mat-form-field-dedupe;
6742
6743 $mat-form-field-dedupe: $mat-form-field-dedupe + 0.00001 !global;
6744}
6745
6746@mixin mat-form-field-typography($config-or-theme) {
6747 $config: mat-get-typography-config($config-or-theme);
6748 // The unit-less line-height from the font config.
6749 $line-height: mat-line-height($config, input);
6750
6751 // The amount to scale the font for the floating label and subscript.
6752 $subscript-font-scale: 0.75;
6753 // The amount to scale the font for the prefix and suffix icons.
6754 $prefix-suffix-icon-font-scale: 1.5;
6755
6756 // The padding on the infix. Mocks show half of the text size.
6757 $infix-padding: 0.5em;
6758 // The margin applied to the form-field-infix to reserve space for the floating label.
6759 $infix-margin-top: 1em * $line-height * $subscript-font-scale;
6760 // Font size to use for the label and subscript text.
6761 $subscript-font-size: $subscript-font-scale * 100%;
6762 // Font size to use for the for the prefix and suffix icons.
6763 $prefix-suffix-icon-font-size: $prefix-suffix-icon-font-scale * 100%;
6764 // The space between the bottom of the .mat-form-field-flex area and the subscript wrapper.
6765 // Mocks show half of the text size, but this margin is applied to an element with the subscript
6766 // text font size, so we need to divide by the scale factor to make it half of the original text
6767 // size.
6768 $subscript-margin-top: 0.5em / $subscript-font-scale;
6769 // The padding applied to the form-field-wrapper to reserve space for the subscript, since it's
6770 // absolutely positioned. This is a combination of the subscript's margin and line-height, but we
6771 // need to multiply by the subscript font scale factor since the wrapper has a larger font size.
6772 $wrapper-padding-bottom: ($subscript-margin-top + $line-height) * $subscript-font-scale;
6773
6774 .mat-form-field {
6775 @include mat-typography-level-to-styles($config, input);
6776 }
6777
6778 .mat-form-field-wrapper {
6779 padding-bottom: $wrapper-padding-bottom;
6780 }
6781
6782 .mat-form-field-prefix,
6783 .mat-form-field-suffix {
6784 // Allow icons in a prefix or suffix to adapt to the correct size.
6785 .mat-icon {
6786 font-size: $prefix-suffix-icon-font-size;
6787 line-height: $line-height;
6788 }
6789
6790 // Allow icon buttons in a prefix or suffix to adapt to the correct size.
6791 .mat-icon-button {
6792 height: $prefix-suffix-icon-font-scale * 1em;
6793 width: $prefix-suffix-icon-font-scale * 1em;
6794
6795 .mat-icon {
6796 height: $line-height * 1em;
6797 line-height: $line-height;
6798 }
6799 }
6800 }
6801
6802 .mat-form-field-infix {
6803 padding: $infix-padding 0;
6804 // Throws off the baseline if we do it as a real margin, so we do it as a border instead.
6805 border-top: $infix-margin-top solid transparent;
6806 }
6807
6808 .mat-form-field-can-float {
6809 &.mat-form-field-should-float .mat-form-field-label,
6810 .mat-input-server:focus + .mat-form-field-label-wrapper .mat-form-field-label {
6811 @include _mat-form-field-label-floating(
6812 $subscript-font-scale, $infix-padding, $infix-margin-top);
6813 }
6814
6815 // Server-side rendered matInput with a label attribute but label not shown
6816 // (used as a pure CSS stand-in for mat-form-field-should-float).
6817 .mat-input-server[label]:not(:label-shown) + .mat-form-field-label-wrapper
6818 .mat-form-field-label {
6819 @include _mat-form-field-label-floating(
6820 $subscript-font-scale, $infix-padding, $infix-margin-top);
6821 }
6822 }
6823
6824 .mat-form-field-label-wrapper {
6825 top: -$infix-margin-top;
6826 padding-top: $infix-margin-top;
6827 }
6828
6829 .mat-form-field-label {
6830 top: $infix-margin-top + $infix-padding;
6831 }
6832
6833 .mat-form-field-underline {
6834 // We want the underline to start at the end of the content box, not the padding box,
6835 // so we move it up by the padding amount.
6836 bottom: $wrapper-padding-bottom;
6837 }
6838
6839 .mat-form-field-subscript-wrapper {
6840 font-size: $subscript-font-size;
6841 margin-top: $subscript-margin-top;
6842
6843 // We want the subscript to start at the end of the content box, not the padding box,
6844 // so we move it up by the padding amount (adjusted for the smaller font size);
6845 top: calc(100% - #{$wrapper-padding-bottom / $subscript-font-scale});
6846 }
6847
6848 @include mat-form-field-legacy-typography($config);
6849 @include mat-form-field-standard-typography($config);
6850 @include mat-form-field-fill-typography($config);
6851 @include mat-form-field-outline-typography($config);
6852}
6853
6854@mixin mat-form-field-density($config-or-theme) {
6855 $density-scale: mat-get-density-config($config-or-theme);
6856 @include mat-private-form-field-legacy-density($density-scale);
6857 @include mat-private-form-field-standard-density($density-scale);
6858 @include mat-private-form-field-fill-density($density-scale);
6859 @include mat-private-form-field-outline-density($density-scale);
6860}
6861
6862@mixin mat-form-field-theme($theme-or-color-config) {
6863 $theme: mat-private-legacy-get-theme($theme-or-color-config);
6864 @include mat-private-check-duplicate-theme-styles($theme, 'mat-form-field') {
6865 $color: mat-get-color-config($theme);
6866 $density: mat-get-density-config($theme);
6867 $typography: mat-get-typography-config($theme);
6868
6869 @if $color != null {
6870 @include mat-form-field-color($color);
6871 }
6872 @if $density != null {
6873 @include mat-form-field-density($density);
6874 }
6875 @if $typography != null {
6876 @include mat-form-field-typography($typography);
6877 }
6878 }
6879}
6880
6881
6882
6883
6884
6885$mat-tree-node-height: 48px !default;
6886// Minimum height for tree nodes in highest density is difficult to determine as
6887// developers can display arbitrary content. We use a minimum height which ensures
6888// that common content placed in tree nodes does not exceed (e.g. icons, checkboxes).
6889$mat-tree-node-minimum-height: 24px !default;
6890$mat-tree-node-maximum-height: $mat-tree-node-height !default;
6891
6892$mat-tree-density-config: (
6893 height: (
6894 default: $mat-tree-node-height,
6895 maximum: $mat-tree-node-maximum-height,
6896 minimum: $mat-tree-node-minimum-height,
6897 )
6898) !default;
6899
6900
6901@mixin mat-tree-color($config-or-theme) {
6902 $config: mat-get-color-config($config-or-theme);
6903 $background: map-get($config, background);
6904 $foreground: map-get($config, foreground);
6905
6906 .mat-tree {
6907 background: mat-color($background, 'card');
6908 }
6909
6910 .mat-tree-node,
6911 .mat-nested-tree-node {
6912 color: mat-color($foreground, text);
6913 }
6914}
6915
6916@mixin mat-tree-typography($config-or-theme) {
6917 $config: mat-get-typography-config($config-or-theme);
6918 .mat-tree {
6919 font-family: mat-font-family($config);
6920 }
6921
6922 .mat-tree-node,
6923 .mat-nested-tree-node {
6924 font-weight: mat-font-weight($config, body-1);
6925 font-size: mat-font-size($config, body-1);
6926 }
6927}
6928
6929@mixin mat-tree-density($config-or-theme) {
6930 $density-scale: mat-get-density-config($config-or-theme);
6931 $height: mat-private-density-prop-value($mat-tree-density-config, $density-scale, height);
6932
6933 @include mat-private-density-legacy-compatibility() {
6934 .mat-tree-node {
6935 min-height: $height;
6936 }
6937 }
6938}
6939
6940@mixin mat-tree-theme($theme-or-color-config) {
6941 $theme: mat-private-legacy-get-theme($theme-or-color-config);
6942 @include mat-private-check-duplicate-theme-styles($theme, 'mat-tree') {
6943 $color: mat-get-color-config($theme);
6944 $density: mat-get-density-config($theme);
6945 $typography: mat-get-typography-config($theme);
6946
6947 @if $color != null {
6948 @include mat-tree-color($color);
6949 }
6950 @if $density != null {
6951 @include mat-tree-density($density);
6952 }
6953 @if $typography != null {
6954 @include mat-tree-typography($typography);
6955 }
6956 }
6957}
6958
6959
6960
6961
6962// Includes all of the typographic styles.
6963@mixin angular-material-typography($config-or-theme: null) {
6964 $config: if(mat-private-is-theme-object($config-or-theme),
6965 mat-get-typography-config($config-or-theme), $config-or-theme);
6966
6967 // If no actual color configuration has been specified, create a default one.
6968 @if not $config {
6969 $config: mat-typography-config();
6970 }
6971
6972 // TODO: COMP-309: Do not use individual mixins. Instead, use the all-theme mixin and only
6973 // specify a `typography` config while setting `color` and `density` to `null`. This is currently
6974 // not possible as it would introduce a circular dependency for typography because the `mat-core`
6975 // mixin that is transitively loaded by the `all-theme` file, imports `all-typography` which
6976 // would then load `all-theme` again. This ultimately results a circular dependency.
6977
6978 @include mat-badge-typography($config);
6979 @include mat-base-typography($config);
6980 @include mat-autocomplete-typography($config);
6981 @include mat-bottom-sheet-typography($config);
6982 @include mat-button-typography($config);
6983 @include mat-button-toggle-typography($config);
6984 @include mat-card-typography($config);
6985 @include mat-checkbox-typography($config);
6986 @include mat-chips-typography($config);
6987 @include mat-divider-typography($config);
6988 @include mat-table-typography($config);
6989 @include mat-datepicker-typography($config);
6990 @include mat-dialog-typography($config);
6991 @include mat-expansion-panel-typography($config);
6992 @include mat-form-field-typography($config);
6993 @include mat-grid-list-typography($config);
6994 @include mat-icon-typography($config);
6995 @include mat-input-typography($config);
6996 @include mat-menu-typography($config);
6997 @include mat-paginator-typography($config);
6998 @include mat-progress-bar-typography($config);
6999 @include mat-progress-spinner-typography($config);
7000 @include mat-radio-typography($config);
7001 @include mat-select-typography($config);
7002 @include mat-sidenav-typography($config);
7003 @include mat-slide-toggle-typography($config);
7004 @include mat-slider-typography($config);
7005 @include mat-stepper-typography($config);
7006 @include mat-sort-typography($config);
7007 @include mat-tabs-typography($config);
7008 @include mat-toolbar-typography($config);
7009 @include mat-tooltip-typography($config);
7010 @include mat-list-typography($config);
7011 @include mat-option-typography($config);
7012 @include mat-optgroup-typography($config);
7013 @include mat-snack-bar-typography($config);
7014 @include mat-tree-typography($config);
7015}
7016
7017
7018// Mixin that renders all of the core styles that are not theme-dependent.
7019@mixin mat-core($typography-config: null) {
7020 @include angular-material-typography($typography-config);
7021 @include mat-ripple();
7022 @include cdk-a11y();
7023 @include cdk-overlay();
7024 @include cdk-text-field();
7025
7026 @include mat-private-strong-focus-indicators-positioning();
7027 @include _mat-mdc-core();
7028}
7029
7030@mixin mat-core-color($config-or-theme) {
7031 $config: mat-get-color-config($config-or-theme);
7032 // Wrapper element that provides the theme background when the user's content isn't
7033 // inside of a `mat-sidenav-container`. Note that we need to exclude the ampersand
7034 // selector in case the mixin is included at the top level.
7035 .mat-app-background#{if(&, ', &.mat-app-background', '')} {
7036 $background: map-get($config, background);
7037 $foreground: map-get($config, foreground);
7038
7039 background-color: mat-color($background, background);
7040 color: mat-color($foreground, text);
7041 }
7042
7043 // Provides external CSS classes for each elevation value. Each CSS class is formatted as
7044 // `mat-elevation-z$zValue` where `$zValue` corresponds to the z-space to which the element is
7045 // elevated.
7046 @for $zValue from 0 through 24 {
7047 .#{$mat-elevation-prefix}#{$zValue} {
7048 @include mat-private-theme-elevation($zValue, $config);
7049 }
7050 }
7051
7052 // Marker that is used to determine whether the user has added a theme to their page.
7053 @at-root {
7054 .mat-theme-loaded-marker {
7055 display: none;
7056 }
7057 }
7058}
7059
7060// Mixin that renders all of the core styles that depend on the theme.
7061@mixin mat-core-theme($theme-or-color-config) {
7062 $theme: mat-private-legacy-get-theme($theme-or-color-config);
7063 // Wrap the sub-theme includes in the duplicate theme styles mixin. This ensures that
7064 // there won't be multiple warnings. e.g. if `mat-core-theme` reports a warning, then
7065 // the imported themes (such as `mat-ripple-theme`) should not report again.
7066 @include mat-private-check-duplicate-theme-styles($theme, 'mat-core') {
7067 @include mat-ripple-theme($theme);
7068 @include mat-option-theme($theme);
7069 @include mat-optgroup-theme($theme);
7070 @include mat-pseudo-checkbox-theme($theme);
7071
7072 $color: mat-get-color-config($theme);
7073 @if $color != null {
7074 @include mat-core-color($color);
7075 }
7076 }
7077}
7078
7079// Mixin that renders all of the core MDC styles. Private mixin included with `mat-core`.
7080@mixin _mat-mdc-core() {
7081 @include _mat-mdc-strong-focus-indicators-positioning();
7082}
7083
7084// Mixin that ensures focus indicator host elements are positioned so that the focus indicator
7085// pseudo element within is positioned relative to the host. Private mixin included within
7086// `_mat-mdc-core`.
7087@mixin _mat-mdc-strong-focus-indicators-positioning() {
7088 .mat-mdc-focus-indicator {
7089 position: relative;
7090 }
7091}
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129// Create a theme.
7130@mixin angular-material-theme($theme-or-color-config) {
7131 $dedupe-key: 'angular-material-theme';
7132 @include mat-private-check-duplicate-theme-styles($theme-or-color-config, $dedupe-key) {
7133 @include mat-core-theme($theme-or-color-config);
7134 @include mat-autocomplete-theme($theme-or-color-config);
7135 @include mat-badge-theme($theme-or-color-config);
7136 @include mat-bottom-sheet-theme($theme-or-color-config);
7137 @include mat-button-theme($theme-or-color-config);
7138 @include mat-button-toggle-theme($theme-or-color-config);
7139 @include mat-card-theme($theme-or-color-config);
7140 @include mat-checkbox-theme($theme-or-color-config);
7141 @include mat-chips-theme($theme-or-color-config);
7142 @include mat-table-theme($theme-or-color-config);
7143 @include mat-datepicker-theme($theme-or-color-config);
7144 @include mat-dialog-theme($theme-or-color-config);
7145 @include mat-divider-theme($theme-or-color-config);
7146 @include mat-expansion-panel-theme($theme-or-color-config);
7147 @include mat-form-field-theme($theme-or-color-config);
7148 @include mat-grid-list-theme($theme-or-color-config);
7149 @include mat-icon-theme($theme-or-color-config);
7150 @include mat-input-theme($theme-or-color-config);
7151 @include mat-list-theme($theme-or-color-config);
7152 @include mat-menu-theme($theme-or-color-config);
7153 @include mat-paginator-theme($theme-or-color-config);
7154 @include mat-progress-bar-theme($theme-or-color-config);
7155 @include mat-progress-spinner-theme($theme-or-color-config);
7156 @include mat-radio-theme($theme-or-color-config);
7157 @include mat-select-theme($theme-or-color-config);
7158 @include mat-sidenav-theme($theme-or-color-config);
7159 @include mat-slide-toggle-theme($theme-or-color-config);
7160 @include mat-slider-theme($theme-or-color-config);
7161 @include mat-stepper-theme($theme-or-color-config);
7162 @include mat-sort-theme($theme-or-color-config);
7163 @include mat-tabs-theme($theme-or-color-config);
7164 @include mat-toolbar-theme($theme-or-color-config);
7165 @include mat-tooltip-theme($theme-or-color-config);
7166 @include mat-tree-theme($theme-or-color-config);
7167 @include mat-snack-bar-theme($theme-or-color-config);
7168 }
7169}
7170
7171
7172
7173// Includes all of the color styles.
7174@mixin angular-material-color($config-or-theme) {
7175 // In case a theme object has been passed instead of a configuration for
7176 // the color system, extract the color config from the theme object.
7177 $config: if(mat-private-is-theme-object($config-or-theme),
7178 mat-get-color-config($config-or-theme), $config-or-theme);
7179
7180 @if $config == null {
7181 @error 'No color configuration specified.';
7182 }
7183
7184 @include angular-material-theme((
7185 color: $config,
7186 typography: null,
7187 density: null,
7188 ));
7189}
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200// Includes all of the density styles.
7201@mixin angular-material-density($config-or-theme) {
7202 // In case a theme object has been passed instead of a configuration for
7203 // the density system, extract the density config from the theme object.
7204 $config: if(mat-private-is-theme-object($config-or-theme),
7205 mat-get-density-config($config-or-theme), $config-or-theme);
7206
7207 @if $config == null {
7208 @error 'No density configuration specified.';
7209 }
7210
7211 // TODO: COMP-309: Do not use individual mixins. Instead, use the all-theme mixin and only
7212 // specify a `density` config while setting `color` and `typography` to `null`. This is currently
7213 // not possible as it would introduce a circular dependency for density because the `mat-core`
7214 // mixin that is transitively loaded by the `all-theme` file, imports `all-density` which
7215 // would then load `all-theme` again. This ultimately results a circular dependency.
7216
7217 @include mat-expansion-panel-density($config);
7218 @include mat-stepper-density($config);
7219 @include mat-toolbar-density($config);
7220 @include mat-tree-density($config);
7221 @include mat-paginator-density($config);
7222 @include mat-form-field-density($config);
7223 @include mat-button-toggle-density($config);
7224}
7225
7226
7227