If you are new to Sass, you’ve probably heard that it’s possible to create your own functions, as well as what’s known as mixins. Let’s start with what a function is before moving on to mixins.
In computer science, a function is a chunk of
code that returns a result, possibly accepting arguments. It’s an ideal
way to extract repeated pieces of code into a single reusable pattern. As
a consequence, functions exist in almost all programming languages, even
CSS! Think about it—when writing
rgba(..), we use CSS functions already. What’s
interesting is that Sass not only provides a lot of built-in functions, it
also provides authors with a way to define custom functions:
// Using the `darken(..)` ...