Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Sass Basics #2
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
jina
April 22, 2014
Design
200
1
Share
Sass Basics #2
A beginner-level presentation I gave internally at work to teach the basics of Sass.
jina
April 22, 2014
More Decks by jina
See All by jina
Design Systems are for People
jina
1
1k
Design Tokens in Design Systems
jina
9
29k
Designing a Design System
jina
34
7.7k
Living Design Systems
jina
42
2.5M
Lightning Design System
jina
6
690
Sass & Style Guides
jina
11
520
Designing for Enterprise
jina
4
250
Refactoring Web Interfaces
jina
20
1k
In Search of the Single Source of Truth
jina
1
430
Other Decks in Design
See All in Design
decksh object reference
ajstarks
2
1.6k
Storyboard Assignment: Storyboard from Comic Strip
lynteo
3
270
文化のデザイン - Soft Impact of Design
atsushihomma
0
200
プロダクトデザイナーに学ぶ、『見る気が起きる』ダッシュボードの作り方 / Creating Engaging Dashboards: Lessons from Product Designers
yamamotoyuta
2
800
CULTURE DECK/Marketing Director
mhand01
0
1.2k
I.A. como meio, não como fim. Dados + IA e até onde vai a promessa?
videlvequio
0
300
2026の目標「もっと定量的に事業、会社へ貢献する!」
yuri_ohashi
0
820
「バイブコーディングって何?」から始まった、 AIとの一年間と、その先のこと
seto
0
520
研修担当者が一番伸びた 熊本市役所✕AI『泥臭いAI研修』のワークショップ設計について
garyuten
2
370
「見せる」登壇資料デザインの極意
takanorip
3
810
2026_01_07_3DプリントはじめましたLT.pdf
hideakitakechi
0
180
UI生成の鍵は要件整理 -デザインプロセスのエッセンスを プロンプト作成に取り入れよう-
abokadotyann
3
800
Featured
See All Featured
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.2k
Technical Leadership for Architectural Decision Making
baasie
3
360
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
231
23k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
290
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
190
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.1k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
1.9k
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
460
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
130
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
62
54k
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.1k
Transcript
JINA BOLTON SENIOR PRODUCT DESIGNER SALESFORCE UX Sass Basics #2
…PREVIOUSLY IN Sass Basics #1 INTRODUCTION TO SASS COMMENTING NESTING
VARIABLES
Sass Basics #2 INTRODUCTION TO MIXINS PASSING ARGUMENTS CONTENT BLOCKS
MIXIN LIBRARIES
SASSMEISTER.COM
CSS Output SCSS .thingy { background: #eee; color: #444; }
@mixin module { background: #eee; color: #444; } .thingy { @include module; }
Sass SCSS =module background: #eee color: #444 @mixin module {
background: #eee; color: #444; }
You can nest selectors in a mixin.
CSS Output SCSS .thingy { background: #eee; } .thingy .this
{ color: #444; } @mixin module { background: #eee; .this { color: #444; } } .thingy { @include module; }
You can include mixins outside of rules…
CSS Output SCSS .this { color: #444; } .that {
color: #444; } @mixin module { .this { color: #444; } .that { color: #ccc; } } @include module;
…unless you directly define properties or parent selectors.
CSS Output SCSS Invalid CSS after "...lor: #ccc; }} ":
expected "{", was "@include module;" @mixin module { color: #444; &.that { color: #ccc; } } @include module;
You can include other mixins in mixins.
CSS Output SCSS .thingy { background: #222; color: #ccc; }
.thingy a { color: #fff; } @mixin dark-theme { background: #222; color: #ccc; } @mixin module { @include dark-theme; a { color: #fff; } } .thingy { @include module; }
You can pass in arguments.
CSS Output SCSS .thingy1 { background: #eee; color: #444; }
.thingy2 { background: #eee; color: purple; } .thingy3 { background: green; color: red; } .thingy4 { background: blue; color: #444; } @mixin module($text: #444, $background: #eee) { background: $background; color: $text; } .thingy1 { @include module; } .thingy2 { @include module(purple); } .thingy3 { @include module(red, green); } .thingy4 { @include module($background: blue); }
You can pass in content blocks.
CSS Output SCSS * html .thingy1 { display: inline; }
@mixin ie6-only { * html { @content; } } @include ie6-only { .thingy1 { display: inline; } }
With great power, comes great responsibility ;-)
Every time you use a Mixin, you output that code
again.
SASS-LANG.COM
USE SASSMEISTER TO EXPERIMENT WITH MIXINS. BUILD A BASIC MIXIN
LIBRARY NEXT WEEK: EXTENDING & PLACEHOLDER SELECTORS your homework