Fireship · @fireship

Tailwind in 100 Seconds

Uploaded August 26, 2021 · Length 2:21

Tailwind in 100 Seconds

Summary

Learn how to use Tailwind CSS for building websites with utility classes and customizable design system.

  • tailwind css
  • css utility classes
  • responsive design
  • design system
  • css frameworks

Transcript preview

The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.

  1. 0:00

    tailwind a massive collection of tiny

  2. 0:02

    css utility classes for quickly and

  3. 0:05

    consistently building good-looking

  4. 0:07

    websites css is hard design is also hard

  5. 0:10

    but naming your css classes in a sane

  6. 0:12

    way is virtually impossible frameworks

  7. 0:14

    like bootstrap and material address this

  8. 0:16

    challenge by creating styles for high

  9. 0:18

    level components things like buttons

  10. 0:20

    drop downs and forms tailwind takes a

  11. 0:23

    more functional approach by providing

  12. 0:24

    you with utility classes that can be

  13. 0:26

    composed together to build components

  14. 0:28

    like this instead of using the card

  15. 0:30

    class like you might in bootstrap you

  16. 0:32

    combine utility classes like flex to

  17. 0:34

    make it a flexbox p to give it padding m

  18. 0:36

    for margin and hundreds of others to

  19. 0:38

    control things like color shadows and so

  20. 0:40

    on in addition every utility can be

  21. 0:42

    applied conditionally you have variants

  22. 0:44

    like small medium and large for

  23. 0:46

    responsive designs along with a bunch of

  24. 0:48

    pseudo-selectors like hover and focus to

  25. 0:50

    handle state changes or dark to render

  26. 0:53

    different colors when dark mode is

  27. 0:54

    enabled this approach gives you a lot

  28. 0:56

    more freedom over your creativity

  29. 0:58

    compared to other css frameworks while

  30. 1:00

    at the same time following the rules of

  31. 1:02

    a design system that you don't get with

  32. 1:04

    plain css it lives in the sweet spot

  33. 1:06

    between convention and configuration

  34. 1:08

    however it does produce some ugly ass

  35. 1:10

    html you've got tons of hard to read

  36. 1:12

    duplicated class names here as your ui

  37. 1:15

    grows in complexity code duplication is

  38. 1:17

    inevitable but you can avoid it by

  39. 1:19

    creating reusable components with your

  40. 1:21

    favorite javascript framework or by

  41. 1:22

    using the apply directive in css to take

  42. 1:25

    tailwind classes and compose them into a

  43. 1:27

    single concise class name another

  44. 1:29

    concern you may have is performance

  45. 1:31

    because tailwind weighs in at over 3 500

  46. 1:34

    kilobytes but when you go to build for

  47. 1:35

    production it will automatically purge

  48. 1:38

    any unused utility from the final bundle

  49. 1:40

    resulting in minimal dead code and thus

  50. 1:42

    faster page loads but who has time to

  51. 1:45

    learn and memorize all these different

  52. 1:46

    utility classes where tailwind really

  53. 1:48

    shines is with its tooling you don't

  54. 1:50

    need to memorize much because vs code

  55. 1:52

    will auto-complete every tailwind class

  56. 1:54

    if you're not sure what it does just

  57. 1:56

    hover over it and it will show you the

  58. 1:57

    equivalent code in plain css and if