Fireship · @fireship
Tailwind in 100 Seconds
Uploaded August 26, 2021 · Length 2:21
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.
- 0:00
tailwind a massive collection of tiny
- 0:02
css utility classes for quickly and
- 0:05
consistently building good-looking
- 0:07
websites css is hard design is also hard
- 0:10
but naming your css classes in a sane
- 0:12
way is virtually impossible frameworks
- 0:14
like bootstrap and material address this
- 0:16
challenge by creating styles for high
- 0:18
level components things like buttons
- 0:20
drop downs and forms tailwind takes a
- 0:23
more functional approach by providing
- 0:24
you with utility classes that can be
- 0:26
composed together to build components
- 0:28
like this instead of using the card
- 0:30
class like you might in bootstrap you
- 0:32
combine utility classes like flex to
- 0:34
make it a flexbox p to give it padding m
- 0:36
for margin and hundreds of others to
- 0:38
control things like color shadows and so
- 0:40
on in addition every utility can be
- 0:42
applied conditionally you have variants
- 0:44
like small medium and large for
- 0:46
responsive designs along with a bunch of
- 0:48
pseudo-selectors like hover and focus to
- 0:50
handle state changes or dark to render
- 0:53
different colors when dark mode is
- 0:54
enabled this approach gives you a lot
- 0:56
more freedom over your creativity
- 0:58
compared to other css frameworks while
- 1:00
at the same time following the rules of
- 1:02
a design system that you don't get with
- 1:04
plain css it lives in the sweet spot
- 1:06
between convention and configuration
- 1:08
however it does produce some ugly ass
- 1:10
html you've got tons of hard to read
- 1:12
duplicated class names here as your ui
- 1:15
grows in complexity code duplication is
- 1:17
inevitable but you can avoid it by
- 1:19
creating reusable components with your
- 1:21
favorite javascript framework or by
- 1:22
using the apply directive in css to take
- 1:25
tailwind classes and compose them into a
- 1:27
single concise class name another
- 1:29
concern you may have is performance
- 1:31
because tailwind weighs in at over 3 500
- 1:34
kilobytes but when you go to build for
- 1:35
production it will automatically purge
- 1:38
any unused utility from the final bundle
- 1:40
resulting in minimal dead code and thus
- 1:42
faster page loads but who has time to
- 1:45
learn and memorize all these different
- 1:46
utility classes where tailwind really
- 1:48
shines is with its tooling you don't
- 1:50
need to memorize much because vs code
- 1:52
will auto-complete every tailwind class
- 1:54
if you're not sure what it does just
- 1:56
hover over it and it will show you the
- 1:57
equivalent code in plain css and if


