O'Reilly logo

Jump Start Sass by Miriam Suzanne, Hugo Giraudel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 4Functions and Mixins

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.

Functions

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 url(..) or 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(..)` ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required