Fireship · @fireship
Sass in 100 Seconds
Uploaded April 27, 2021 · Length 2:31
Summary
learn sass in 100 seconds, extending css with superpowers, variables, nesting, and more.
- sass
- css
- variables
- nesting
- mixins
- programming
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
syntactically awesome stylesheets or
- 0:02
sass is a language that can extend your
- 0:04
css with super powers
- 0:06
modern uis are extremely complex and if
- 0:08
you attempt to build one with plain css
- 0:10
you'll find yourself repeating yourself
- 0:11
often sas comes to the rescue by
- 0:14
providing a compiler
- 0:15
that allows us to write style sheets in
- 0:16
a completely different language well two
- 0:18
different languages to be exact the
- 0:20
original
- 0:20
indented syntax that you find in dot
- 0:22
sass files removes the syntactic salt of
- 0:25
semicolons and curly braces
- 0:27
[Applause]
- 0:28
[Music]
- 0:29
but the more popular version is the
- 0:31
superset syntax that you find in scss
- 0:33
files
- 0:34
here you can write regular css then
- 0:36
extend it with additional bonus features
- 0:38
as needed
- 0:38
sas has been around for nearly 15 years
- 0:40
and one of its original killer features
- 0:42
was variables
- 0:43
use a dollar sign to name a variable
- 0:45
then reference it somewhere else in your
- 0:47
code
- 0:47
now if that value ever changes you only
- 0:49
have to update one line of code css
- 0:51
introduced its own native variables a
- 0:53
few years ago
- 0:53
but the advantages don't stop there
- 0:55
killer feature number two is nesting in
- 0:57
many cases
- 0:58
classes are used as name spaces which
- 1:00
means they're often duplicated over and
- 1:02
over again we can avoid this duplication
- 1:04
by nesting styles inside the parent by
- 1:07
default these classes will apply to
- 1:09
descendant elements or
- 1:10
they can be applied to a direct sibling
- 1:12
by using the ampersand which
- 1:13
itself is a tool that tells sas to
- 1:15
combine the parent selector with the
- 1:17
nested child selector
- 1:18
now one other issue with css is that
- 1:20
you'll often find yourself including
- 1:22
a similar group of styles on multiple
- 1:24
classes mix-ins allow you to encapsulate
- 1:26
a group of styles
- 1:27
then apply those styles anywhere in your
- 1:29
code using the include keyword
- 1:31
mixons can also take arguments to create
- 1:33
a large number of similar classes
- 1:35
programmatically
- 1:36
like a bunch of different colored
- 1:37
buttons for example in addition
- 1:39
sas provides a whole suite of tools to
- 1:41
help you write more programmatic code
- 1:43
use if or else in a mixin for
- 1:44
conditional logic or create an array of
- 1:46
values with a variable then loop over
- 1:48
them with each
- 1:49
and you might even extract all this
- 1:50
logic into a reusable function
- 1:52
or sas might already have a built-in
- 1:54
function for you ready to go
- 1:56
if you need to adjust a color you can
- 1:57
use the lighten or darken functions to


