Fireship · @fireship

Sass in 100 Seconds

Uploaded April 27, 2021 · Length 2:31

Sass in 100 Seconds

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.

  1. 0:00

    syntactically awesome stylesheets or

  2. 0:02

    sass is a language that can extend your

  3. 0:04

    css with super powers

  4. 0:06

    modern uis are extremely complex and if

  5. 0:08

    you attempt to build one with plain css

  6. 0:10

    you'll find yourself repeating yourself

  7. 0:11

    often sas comes to the rescue by

  8. 0:14

    providing a compiler

  9. 0:15

    that allows us to write style sheets in

  10. 0:16

    a completely different language well two

  11. 0:18

    different languages to be exact the

  12. 0:20

    original

  13. 0:20

    indented syntax that you find in dot

  14. 0:22

    sass files removes the syntactic salt of

  15. 0:25

    semicolons and curly braces

  16. 0:27

    [Applause]

  17. 0:28

    [Music]

  18. 0:29

    but the more popular version is the

  19. 0:31

    superset syntax that you find in scss

  20. 0:33

    files

  21. 0:34

    here you can write regular css then

  22. 0:36

    extend it with additional bonus features

  23. 0:38

    as needed

  24. 0:38

    sas has been around for nearly 15 years

  25. 0:40

    and one of its original killer features

  26. 0:42

    was variables

  27. 0:43

    use a dollar sign to name a variable

  28. 0:45

    then reference it somewhere else in your

  29. 0:47

    code

  30. 0:47

    now if that value ever changes you only

  31. 0:49

    have to update one line of code css

  32. 0:51

    introduced its own native variables a

  33. 0:53

    few years ago

  34. 0:53

    but the advantages don't stop there

  35. 0:55

    killer feature number two is nesting in

  36. 0:57

    many cases

  37. 0:58

    classes are used as name spaces which

  38. 1:00

    means they're often duplicated over and

  39. 1:02

    over again we can avoid this duplication

  40. 1:04

    by nesting styles inside the parent by

  41. 1:07

    default these classes will apply to

  42. 1:09

    descendant elements or

  43. 1:10

    they can be applied to a direct sibling

  44. 1:12

    by using the ampersand which

  45. 1:13

    itself is a tool that tells sas to

  46. 1:15

    combine the parent selector with the

  47. 1:17

    nested child selector

  48. 1:18

    now one other issue with css is that

  49. 1:20

    you'll often find yourself including

  50. 1:22

    a similar group of styles on multiple

  51. 1:24

    classes mix-ins allow you to encapsulate

  52. 1:26

    a group of styles

  53. 1:27

    then apply those styles anywhere in your

  54. 1:29

    code using the include keyword

  55. 1:31

    mixons can also take arguments to create

  56. 1:33

    a large number of similar classes

  57. 1:35

    programmatically

  58. 1:36

    like a bunch of different colored

  59. 1:37

    buttons for example in addition

  60. 1:39

    sas provides a whole suite of tools to

  61. 1:41

    help you write more programmatic code

  62. 1:43

    use if or else in a mixin for

  63. 1:44

    conditional logic or create an array of

  64. 1:46

    values with a variable then loop over

  65. 1:48

    them with each

  66. 1:49

    and you might even extract all this

  67. 1:50

    logic into a reusable function

  68. 1:52

    or sas might already have a built-in

  69. 1:54

    function for you ready to go

  70. 1:56

    if you need to adjust a color you can

  71. 1:57

    use the lighten or darken functions to