David
David

Reputation: 4857

Import scss variable into Angular component

Let's say I have the following Angular component:

// src/app/app.component.html
<stars [customColor]="blue">

And I have the following scss variable:

// src/_styles.scss
$color: blue;

How can I use the scss variable instead of duplicating blue?

To clarify, I want to access $color in app.component.html or app.component.ts.

Apparently it's possible to configure Webpack in a React app but I'm not sure if this is possible in Angular.

Upvotes: 1

Views: 1202

Answers (1)

Eliran Eliassy
Eliran Eliassy

Reputation: 1600

In your app.component.scss (or star.component.scss) file just import your styles:

@import './../_style.scss'

Then you can use your scss var

Upvotes: 2

Related Questions