SASS Mixins Tutorial
Learn How to Use SASS Mixins

Passionate Software Engineer with three years of experience, dedicated to creating robust and scalable web applications. I have a strong foundation in JavaScript, React, Python, and Node.js, and enjoy working with modern tech stacks to build innovative solutions. I'm committed to writing clean and efficient code, following best practices, and staying updated with the latest industry trends.
Throughout my career, I've gained valuable experience in full-stack development, including frontend design, backend development, and database management. I love solving complex problems and implementing creative solutions that enhance user experiences. I believe in the power of collaboration and thrive in cross-functional teams where I can contribute my skills and learn from others.
Beyond coding, I am an avid learner and enjoy sharing my knowledge with the developer community. I regularly contribute to open-source projects, write technical blog posts, and engage in discussions on emerging technologies. I'm always seeking opportunities to expand my skill set and stay at the forefront of software engineering.
Mixins are an extremely powerful feature of Sass. We use them to group together multiple CSS declarations for reuse throughout our projects.
Say we want to create a mixin to hold the vendor prefixes for a transform property.
In SASS, we’d code it like so:
@mixin transform {
-webkit-transform: rotate(180deg);
-ms-transform: rotate(180deg);
transform: rotate(180deg);
}
To add the mixin into our code, we then use the @include directive, like so:
.navbar {
background-color: red;
padding: 1rem;
ul {
list-style: none;
}
li {
text-align: center;
margin: 1rem;
@include transform;
}
}
All the code in the transform mixin will now be applied to the li element. You can also pass values into your mixins to make them even more flexible.
Instead of adding a specified value, add a name (using a variable, like property) to represent the value like so:
@mixin transform($property) {
-webkit-transform: $property;
-ms-transform: $property;
transform: $property;
}
Now we can pass in whatever value we like, whenever we call the mixin:
@include transform (rotate(20deg));
Conclusion
If you liked this blog post, follow me on Twitter where I post daily about Tech related things!




