It is advisable to utilize the power of @mixins and @include in this scenario.
However, considering that you are working with an existing file (potentially from a third party) that already defines these rules, converting the classes into mixins could prove to be laborious.
If you only need a handful of classes from this file, it might be worth the effort.
You would need to transform:
.btn{
/*
some cool styles
*/
}
to:
@mixin{
/*
cooler styles
*/
}
Nevertheless, as outlined in the Sass documentation, mixins can serve your purpose effectively.
Here is an example of SCSS code:
@mixin reset-list {
margin: 0;
padding: 0;
list-style: none;
}
@mixin horizontal-list {
@include reset-list;
li {
display: inline-block;
margin: {
left: -2px;
right: 2em;
}
}
}
nav ul {
@include horizontal-list;
}
The resulting CSS will be:
nav ul {
margin: 0;
padding: 0;
list-style: none;
}
nav ul li {
display: inline-block;
margin-left: -2px;
margin-right: 2em;
}