Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use SCSS mixins with angular 7

I am getting this error in my angular project.

@include for-desktop-up {...." No mixin named for-desktop-up"

My code in the styles.scss is

@mixin for-desktop-up {
    @media (min-width: 1024px) { @content; }
}

My code in a stylesheet of a component is

@include for-desktop-up {
    //some scss code
}

What am I doing wrong or what is going on?

like image 685
YulePale Avatar asked May 17 '19 15:05

YulePale


People also ask

How do you write mixin in SCSS?

A mixin is defined with the @mixin directive. Tip: A tip on hyphens and underscore in Sass: Hyphens and underscores are considered to be the same. This means that @mixin important-text { } and @mixin important_text { } are considered as the same mixin!

Can I use SCSS in angular?

Using SCSS(Syntactically Awesome Stylesheet) The variable creation is the most useful feature of the SCSS. Using variables in your SCSS based angular project helps you to remove a lot of duplicated code from your style sheets.

What's a mixin SCSS?

Mixins allow you to define styles that can be re-used throughout your stylesheet. They make it easy to avoid using non-semantic classes like .float-left , and to distribute collections of styles in libraries.


1 Answers

Either import the file in component.ts as

styleUrls: ['./styles.scss']

or

use SASS/SCSS import to import in component.scss

@import "styles.scss";
like image 101
dota2pro Avatar answered Sep 28 '22 17:09

dota2pro