Skip to Content
Pragmatic Guide to Sass 3
book

Pragmatic Guide to Sass 3

by Hampton Lintorn Catlin, Michael Lintorn Catlin
July 2016
Intermediate to advanced
130 pages
2h 11m
English
Pragmatic Bookshelf
Content preview from Pragmatic Guide to Sass 3
28Creating Your Own Functions

As well as using functions for things such as manipulating lists and maps, and color manipulation, Sass gives you the ability to create your own functions.

Functions are defined similarly to mixins. You define them using the @function directive. Then you can pass in any arguments. Inside the scope of the function, you can perform any number of tasks using standard Sass. The only main difference from a mixin is that you need to use the @return method if you want to make the function return anything.

You can see this in a simple doubling function example. A variable is passed in ($value), and the function returns the variable multiplied by two. When the function is used in the .sidebar class, it outputs 20px rather ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Jump Start Sass

Jump Start Sass

Hugo Giraudel, Miriam Suzanne
What Employees Want Most in Uncertain Times

What Employees Want Most in Uncertain Times

Kristine W. Powers, Jessica B.B. Diaz
Mastering Sass

Mastering Sass

Luke Watts

Publisher Resources

ISBN: 9781680502060Errata Page