@@ -33,6 +33,7 @@ import {
3333 PortalHostDirective ,
3434} from '@angular/cdk/portal' ;
3535import { first } from '@angular/cdk/rxjs' ;
36+ import { BreakpointObserver , BreakpointState , Breakpoints } from '@angular/cdk/layout' ;
3637import { Observable } from 'rxjs/Observable' ;
3738import { Subject } from 'rxjs/Subject' ;
3839import { MatSnackBarConfig } from './snack-bar-config' ;
@@ -58,6 +59,7 @@ export const HIDE_ANIMATION = '195ms cubic-bezier(0.0,0.0,0.2,1)';
5859 host : {
5960 'role' : 'alert' ,
6061 'class' : 'mat-snack-bar-container' ,
62+ '[class.mobile]' : '_isHandset' ,
6163 '[@state]' : '_animationState' ,
6264 '(@state.done)' : 'onAnimationEnd($event)'
6365 } ,
@@ -90,6 +92,9 @@ export class MatSnackBarContainer extends BasePortalHost implements OnDestroy {
9092 /** Subject for notifying that the snack bar has finished entering the view. */
9193 _onEnter : Subject < any > = new Subject ( ) ;
9294
95+ /** Whether the snackbar is currently displaying on a mobile screen.. */
96+ _isHandset : boolean ;
97+
9398 /** The state of the snack bar animations. */
9499 _animationState = 'void' ;
95100
@@ -100,8 +105,12 @@ export class MatSnackBarContainer extends BasePortalHost implements OnDestroy {
100105 private _ngZone : NgZone ,
101106 private _renderer : Renderer2 ,
102107 private _elementRef : ElementRef ,
103- private _changeDetectorRef : ChangeDetectorRef ) {
108+ private _changeDetectorRef : ChangeDetectorRef ,
109+ breakpointObserver : BreakpointObserver ) {
104110 super ( ) ;
111+ // Listen for the screen matcheing the `Handset` breakpoint to adjust snackbar styling.
112+ breakpointObserver . observe ( Breakpoints . Handset ) . subscribe (
113+ breakpointState => this . _isHandset = breakpointState . matches ) ;
105114 }
106115
107116 /** Attach a component portal as content to this snack bar container. */
0 commit comments