@mixin is a wonderful rule SassScript has. It allows you to write style rules that can be used throughout your stylesheet — basically it helps to create reusable styles.
@mixin helps to create reusable styles and to avoid using non-semantic classes.
Non-semantic classes are the classes that don’t give you an idea of what the particular element represents. They might give an impression of how the element looks like. Some of the examples of non-semantic classes are .green, .float-left, .grid etc.
@mixin also helps in distributing collections of styles in libraries which is another advantage of using it.
How to define @mixin rules?
Using @mixin at-rule we can define @mixin rules.
It basically like JavaScript named or anonymous function declaration.
You can either use @mixin { … } or @mixin name() { … }.
For the @mixin name, you can use Sass identifier. It can contain any kind of statements except the top-level statements.
@mixin can also be used to encapsulate styles which then can be dropped into a single style rule. You can add styles inside @mixin and even nest the style inside other @mixin rules. You can also use @mixin to modify the declared variables.
That’s where @include comes into play. To include the @mixin rules.
@mixin and @include Example
In the following example, we are using @include to include @mixin rules twice and one of them is nested as well.
@mixin rule names treat underscore and hyphens as same. So, reset-list and reset_list both refer to the same @mixin rule.
Source: Sass Docs
examples include mixin sass