How I got married to tailwindcss

A presentation at Stahlstadt.js #24 in February 2020 in Linz, Austria by Klaus

Slide 1

Slide 1

How I got married to tailwindcss Klaus Fischer klaus@supersimple.at @klausinger

Slide 2

Slide 2

Goal

Slide 3

Slide 3

Motivate 3 people to try tailwind!

Slide 4

Slide 4

How is the motivation happening? (Agenda) 1. What is tailwind? 2. What problems does it solve? 3. How did I get convinced? 4. Quickstart 5. Future & Improvements

Slide 5

Slide 5

  1. What is tailwind? A utility-first CSS framework for rapidly building custom designs.

Slide 6

Slide 6

WTF Utility-first

Slide 7

Slide 7

Slide 8

Slide 8

Slide 9

Slide 9

Slide 10

Slide 10

Slide 11

Slide 11

High and DRY

Slide 12

Slide 12

#soDRY

Slide 13

Slide 13

Slide 14

Slide 14

Slide 15

Slide 15

  1. What problems does tailwind solve?

Slide 16

Slide 16

Scope: Think less when styling ‐ Classes instead of CSS properties <span class=”text-primary”> Importante! </span> .text-primary { color: red; line-height: 1.25; } <span class=”text-red leading-tight”> Importante! </span>

Slide 17

Slide 17

Responsive utility classes ‐ Variants supercharge your classes <span class=”text-lg md:text-xl hover:text-red md:hover:text-blue”> Importante! </span>

Slide 18

Slide 18

Establish flexible design systems ‐ Declare your design system/styleguide in tailwind.config.js ‐ Atoms → Components ‐ Build combos for repeating elements (e.g. forms) <input type=”text” class=”tw-input”> .tw-input { @apply px-4 py-3 border border-gray-400 appearance-none; }

Slide 19

Slide 19

It’s CSS only! ‐ No JS components → Use it with your favorite jQuery version JS framework 😉 ‐ Do one thing and do it well ‐ Less cognitive connection between CSS and JS, easier onboarding ‐ More utility-based CSS frameworks: tachyons, …

Slide 20

Slide 20

  1. How did I get convinced?

Slide 21

Slide 21

History lesson! ‐ Bootstrap :( there has to be something better! ‐ uikit 2 → uikit 3 ‐ Utility based → tachyons? ○ 👍 Minimalism, typo 👎 Maintenance ‐ Stick with uikit 3

Slide 22

Slide 22

“We really should try that new thing!”

Slide 23

Slide 23

Make a sustainable choice I won’t regret.

Slide 24

Slide 24

Sustainable choice, huh? ‐ Perf: Generate ALL the classes → purgecss ‐ Low risk project (budget, few tech. unknowns, low maintenance) ‐ Take the time to learn ‐ Encourage enthusiasm ‐ Decide afterwards

Slide 25

Slide 25

“Mkay, gimme half the pill and a way out.”

Slide 26

Slide 26

Technical integration ‐ Symfony Boilerplate + Storyblok ‐ SSR with PHP + twig ‐ SCSS (uikit) ‐ ES6, Vue.js, webpack ‐ Gulp

Slide 27

Slide 27

→ PostCSS

Slide 28

Slide 28

Why PostCSS? ‐ more modular than scss ‐ postcss-preset-env (!!!) ‐ CSS custom properties a.k.a. CSS Variables, imports, nesting

Slide 29

Slide 29

Workflow ‐ Half a day to make it work ‐ VSCode plugin as cheatsheet ‐ Designs → extract design system → typo, colors, spacings ‐ tailwind.config.js overrides ‐ Start building!

Slide 30

Slide 30

  1. tailwindcss Quickstart

Slide 31

Slide 31

tailwindcss Quickstart ‐ Start plain or add to your setup ‐ Don’t panic, use the force search! (it’s really good) ‐ IDE Plugin / Cheatsheet ‐ Component-based approach ‐ Grid, Typography, Spacings (Sample Markdown) ‐ Give yourself some time!

Slide 32

Slide 32

  1. THE FUTURE

Slide 33

Slide 33

Future & Improvements ‐ Order classes: text-red border-red md:text-lg ‐ Improve combo-readability ‐ Combine with JS libs (sliders, modals, … ) ‐ https://www.tailwindui.com/ ‐ Share experiences!

Slide 34

Slide 34

Summary (finally!)

Slide 35

Slide 35

Summary 1. What is tailwind? utility-based 2. What problems does it solve? scope, variants, focused 3. How did I get convinced? Low risk, purgeCSS, enthusiasm 4. Quickstart: pick a project, search docs, IDE plugin 5. Take some time and try it!

Slide 36

Slide 36

Hope you’ve enjoyed, try it! Wanna code tailwind or something else? klaus.fischer@netural.com Klaus Fischer @klausinger

Slide 37

Slide 37

STOP CSS NOW, TALK JS Wanna code tailwind or something else? klaus.fischer@netural.com Klaus Fischer @klausinger