@@ -17,6 +17,7 @@ import {
1717 OnDestroy ,
1818 Renderer2 ,
1919 ChangeDetectorRef ,
20+ ViewEncapsulation ,
2021} from '@angular/core' ;
2122import {
2223 style ,
@@ -75,6 +76,7 @@ export class MdTooltip implements OnDestroy {
7576
7677 private _position : TooltipPosition = 'below' ;
7778 private _disabled : boolean = false ;
79+ private _tooltipClass : string | string [ ] | Set < string > | { [ key : string ] : any } ;
7880
7981 /** Allows the user to define the position of the tooltip relative to the parent element */
8082 @Input ( 'mdTooltipPosition' )
@@ -125,6 +127,16 @@ export class MdTooltip implements OnDestroy {
125127 }
126128 }
127129
130+ /** Classes to be passed to the tooltip. Supports the same syntax as `ngClass`. */
131+ @Input ( 'mdTooltipClass' )
132+ get tooltipClass ( ) { return this . _tooltipClass ; }
133+ set tooltipClass ( value : string | string [ ] | Set < string > | { [ key : string ] : any } ) {
134+ this . _tooltipClass = value ;
135+ if ( this . _tooltipInstance ) {
136+ this . _setTooltipClass ( this . _tooltipClass ) ;
137+ }
138+ }
139+
128140 /** @deprecated */
129141 @Input ( 'md-tooltip' )
130142 get _deprecatedMessage ( ) : string { return this . message ; }
@@ -155,6 +167,11 @@ export class MdTooltip implements OnDestroy {
155167 get _matShowDelay ( ) { return this . showDelay ; }
156168 set _matShowDelay ( v ) { this . showDelay = v ; }
157169
170+ // Properties with `mat-` prefix for nonconflict mode.
171+ @Input ( 'matTooltipClass' )
172+ get _matClass ( ) { return this . tooltipClass ; }
173+ set _matClass ( v ) { this . tooltipClass = v ; }
174+
158175 constructor (
159176 private _overlay : Overlay ,
160177 private _elementRef : ElementRef ,
@@ -190,6 +207,7 @@ export class MdTooltip implements OnDestroy {
190207 this . _createTooltip ( ) ;
191208 }
192209
210+ this . _setTooltipClass ( this . _tooltipClass ) ;
193211 this . _setTooltipMessage ( this . _message ) ;
194212 this . _tooltipInstance . show ( this . _position , delay ) ;
195213 }
@@ -322,6 +340,12 @@ export class MdTooltip implements OnDestroy {
322340 }
323341 } ) ;
324342 }
343+
344+ /** Updates the tooltip class */
345+ private _setTooltipClass ( tooltipClass : string | string [ ] | Set < string > | { [ key : string ] : any } ) {
346+ this . _tooltipInstance . tooltipClass = tooltipClass ;
347+ this . _tooltipInstance . _markForCheck ( ) ;
348+ }
325349}
326350
327351export type TooltipVisibility = 'initial' | 'visible' | 'hidden' ;
@@ -335,6 +359,7 @@ export type TooltipVisibility = 'initial' | 'visible' | 'hidden';
335359 selector : 'md-tooltip-component, mat-tooltip-component' ,
336360 templateUrl : 'tooltip.html' ,
337361 styleUrls : [ 'tooltip.css' ] ,
362+ encapsulation : ViewEncapsulation . None ,
338363 animations : [
339364 trigger ( 'state' , [
340365 state ( 'void' , style ( { transform : 'scale(0)' } ) ) ,
@@ -356,6 +381,9 @@ export class TooltipComponent {
356381 /** Message to display in the tooltip */
357382 message : string ;
358383
384+ /** Classes to be added to the tooltip. Supports the same syntax as `ngClass`. */
385+ tooltipClass : string | string [ ] | Set < string > | { [ key : string ] : any } ;
386+
359387 /** The timeout ID of any current timer set to show the tooltip */
360388 _showTimeoutId : number ;
361389
0 commit comments