Using the SASS Function Form to Apply Host Styles Conditionally | Task

Ole Ersoy
Jul - 31  -  1 min

Scenario

We are styling the :host element of our component and we want the host element font-weight to be bold when the active class is applied to the host element.

Approach

From the Angular SASS Documentation.

Use the function form to apply host styles conditionally by including another selector inside parentheses after :host.

:host(.active) {   font-weight: bold; }