Responsive
Typography
Using Sass to Keep Things Legible
What Is 

Responsive Typography?
Web Typography
• Font faces
• Sizes & scale
• Line height & vertical rhythm
• Line length
Responsive Typography
• Changing values at breakpoints
• Base font size
• Scale interval
• Vertical Rhythm
Why Does

Responsive Typography

Matter?
Responsive Typography with Sass
Responsive Typography with Sass
Responsive Typography with Sass
Responsive Typography with Sass
How Do We Make

Responsive Typography

Easy?
to the Rescue!
Map for Storing Data
• Breakpoint widths
• Typography values
• Base font-size
• Scale
• Vertical Rhythm
Map
$rwd-typography: (
default: (
base-font-size: 16px,
vertical-rhythm: 1.414,
type-scale: 1.2,
min-width: null
),
);
Map
$rwd-typography: (
medium: (
base-font-size: 18px,
vertical-rhythm: 1.5,
type-scale: 1.414,
min-width: 480px
),
);
Map
$rwd-typography: (
large: (
base-font-size: 20px,
vertical-rhythm: 1.618,
type-scale: 1.5,
min-width: 960px
),
);
Map
$rwd-typography: (
xlarge: (
base-font-size: 24px,
vertical-rhythm: 1.618,
type-scale: 1.618,
min-width: 1300px
)
);
List for Storing Labels
• Generate multiple font-sizes on a
consistent scale
• Labels to assign those sizes to
List
$rwd-labels: (
p,
bq,
sh,
h,
hero
);
Loop through Labels
@each $label in $rwd-labels {
%#{$label} {
// loop through
breakpoints
}
}
Loop through Breakpoints
@each $bp, $data in $rwd-
typography {
// $bp = key
// $data = value: nested map
// font-size: ?;
// line-height: ?;
}
Get Font-Size
@function rwd-get-font-size($label, $bp) {
$base—font-size: map-get(map-get($rwd-
typography, $bp), base-font-size);
$type-scale: map-get(map-get($rwd-typography,
$bp), type-scale);
$return: $base-font-size;
@for $i from 1 to index($rwd-labels, $label) {
$return: $return * $type-scale;
}
@return $return;
}
Get Line-Height
@function rwd-get-font-size($label, $bp) {
// same as before, but new var - $font-size
$font-size: X;
  $vertical-rhythm: map-get(map-get($rwd-
typography, $bp), vertical-rhythm);
$vertical-rhythm: $base-font-size *
$vertical-rhythm;
$line-height: ceil($font-size / $vertical-
rhythm) * $vertical-rhythm / $font-size;
$return: join($font-size, $line-height);
@return $return;
}
Using the Values
$values: rwd-generate-font-
size($label, $bp);
font-size: nth($values, 1);
line-height: nth($values, 2);
Extending the Labels
body { @extend %p; }
blockquote { @extend %bq; }
h2 { @extend %sh; }
h1 { @extend %h1; }
.hero { @extend %hero; }
IRL
SassMeister Gist
James Steinbach
jamessteinbach.com
jdsteinbach@gmail.com
@jdsteinbach
/jdsteinbach
CLT Sass
cltsass.com
info@cltsass.com
@CLTSass

More Related Content

PDF
Smarter Grids with Sass and Susy
PDF
Fasten RWD Development with Sass
PDF
Responsive and Fast
PDF
Breaking Free from Bootstrap: Custom Responsive Grids with Sass Susy
PDF
From CSS to Sass in WordPress
PDF
2024 Trend Updates: What Really Works In SEO & Content Marketing
PDF
Storytelling For The Web: Integrate Storytelling in your Design Process
PDF
Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...
Smarter Grids with Sass and Susy
Fasten RWD Development with Sass
Responsive and Fast
Breaking Free from Bootstrap: Custom Responsive Grids with Sass Susy
From CSS to Sass in WordPress
2024 Trend Updates: What Really Works In SEO & Content Marketing
Storytelling For The Web: Integrate Storytelling in your Design Process
Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...

Recently uploaded (20)

PDF
A comparative study of natural language inference in Swahili using monolingua...
PDF
Taming the Chaos: How to Turn Unstructured Data into Decisions
PDF
Five Habits of High-Impact Board Members
PDF
A contest of sentiment analysis: k-nearest neighbor versus neural network
PDF
Produktkatalog für HOBO Datenlogger, Wetterstationen, Sensoren, Software und ...
PDF
Architecture types and enterprise applications.pdf
PPTX
Configure Apache Mutual Authentication
PDF
Enhancing emotion recognition model for a student engagement use case through...
PPT
Module 1.ppt Iot fundamentals and Architecture
PPTX
Microsoft Excel 365/2024 Beginner's training
PDF
Developing a website for English-speaking practice to English as a foreign la...
PDF
Abstractive summarization using multilingual text-to-text transfer transforme...
PDF
Zenith AI: Advanced Artificial Intelligence
PDF
Flame analysis and combustion estimation using large language and vision assi...
PPTX
Modernising the Digital Integration Hub
PPTX
Final SEM Unit 1 for mit wpu at pune .pptx
PPT
Geologic Time for studying geology for geologist
PPTX
2018-HIPAA-Renewal-Training for executives
PDF
Getting started with AI Agents and Multi-Agent Systems
PDF
A Late Bloomer's Guide to GenAI: Ethics, Bias, and Effective Prompting - Boha...
A comparative study of natural language inference in Swahili using monolingua...
Taming the Chaos: How to Turn Unstructured Data into Decisions
Five Habits of High-Impact Board Members
A contest of sentiment analysis: k-nearest neighbor versus neural network
Produktkatalog für HOBO Datenlogger, Wetterstationen, Sensoren, Software und ...
Architecture types and enterprise applications.pdf
Configure Apache Mutual Authentication
Enhancing emotion recognition model for a student engagement use case through...
Module 1.ppt Iot fundamentals and Architecture
Microsoft Excel 365/2024 Beginner's training
Developing a website for English-speaking practice to English as a foreign la...
Abstractive summarization using multilingual text-to-text transfer transforme...
Zenith AI: Advanced Artificial Intelligence
Flame analysis and combustion estimation using large language and vision assi...
Modernising the Digital Integration Hub
Final SEM Unit 1 for mit wpu at pune .pptx
Geologic Time for studying geology for geologist
2018-HIPAA-Renewal-Training for executives
Getting started with AI Agents and Multi-Agent Systems
A Late Bloomer's Guide to GenAI: Ethics, Bias, and Effective Prompting - Boha...
Ad
Ad

Responsive Typography with Sass