Learn Tailwind PDF
Learn Tailwind PDF
Learn Tailwind PDF
presented by
Tailwind CSS Crash Course
Presented by Scrimba & Coder's Tape
A note from the instructor
Welcome to the Scrimba Tailwind CSS Crash Course! Firstly, I want to thank you for joining in and learning
Tailwind in Scrimba's awesome platform. e purpose of this document is to help you learn all of the utility
classes and serve as a guide during the course and beyond. We will start with the basics and build our
knowledge one step at a time. Let's get started!
E01 E11
Welcome Display Modes
E02 E12
Background classes & shades Flexbox
E03 E13
Element sizing is achieved using the Challenge 4 - Block Gallery
w- and h- classes.
E14
Tailwind's Numbering System Responsive Design
Sizing with w-* and h-* classes
E15
E04 Hover Modi er
Challenge 1 - Shades of Blue
E16
E05 Focus Modi er
Padding and margins with p-* , m-* ,
py-* and my-* E17
Combination Modi ers
E06
Styling Text with utility classes Part 1 E18
Other Utilities
E07
Styling Text with utility classes Part 2 E19
Challenge 5 - Input Component
E08
Challenge 2 - Text Styling E20
Challenge 6 - Employee Card
E09
Borders E21
Final Course Project - Landing Page
E10
Challenge 3 - Button Challenge
E01
Welcome
No notes here.
E02
Background classes & shades
is set of classes change the background color of an element using a scale of 100-900 for shades and a palette of
over 90 shades.
.bg-*-{100-900} {}
Continues to all of the available default sizes 12, 16, 20, 24, 32, 40, 48, 56, 64,
Sizing in percentages
1/2... 1/{3, 4, 5, 6, 12)
Sizing utilities
screen, full
E04
Challenge 1 - Shades of Blue
Solution
<body class="bg-gray-200">
</body>
E05
Padding and margins with p-* , m-* , py-* and my-*
ese classes add padding and margin to an element using the Tailwind numbering system.
.p-* {}
.m-* {}
.p{x, y}-* {}
.m{x, y}-* {}
E06
Styling Text with utility classes Part 1
Font styling is a huge part of any design and Tailwind has plenty of classes that we can use to style the text on our
apps. It even includes utility classes for transformations like uppercase.
// Fonts
.font-sans {} // Helvetica or similar
.font-serif {} // Times New Roman or similar
.font-mono {} // Monospace or similar
// Sizing
.text-xs {} // .75rem;
.text-sm {} // .875rem;
.text-base {} // 1rem;
.text-lg {} // 1.125rem;
.text-xl {} // 1.25rem;
.text-2xl {} // 1.5rem;
.text-3xl {} // 1.875rem;
.text-4xl {} // 2.25rem;
.text-5xl {} // 3rem;
.text-6xl {} // 4rem;
// Text Align
.text-left {}
.text-center {}
.text-right {}
.text-justify {}
// Text Color
.text-{color}-{shade (100-900)} {}
E07
Styling Text with utility classes Part 2
In part 2, we continue to explore the available classes in Tailwind CSS.
// Styling
.italic {}
.not-italic {}
// Letter Spacing
.tracking-tighter {} // -0.05em
.tracking-tight {} // -0.025em
.tracking-normal {} // 0
.tracking-wide {} // 0.025em
.tracking-wider {} // 0.05em
.tracking-widest {} // 0.1em
// Line Height/Spacing
.leading-none {} // 1
.leading-tight {} // 1.25
.leading-snug {} // 1.375
.leading-normal {} // 1.5
.leading-relaxed {} // 1.625
.leading-loose {} // 2
// Text Decorations
.underline {}
.line-through {}
.no-underline {}
// Text Transform
.uppercase {}
.lowercase {}
.capitalize {}
.normal-case {}
E08
Challenge 2 - Text Styling
Solution
<body>
<!-- Title case heading 1 text in dark gray -->
<h1 class="capitalize text-xl text-gray-900">
Lorem ipsum dolor sit amet consectetur.
</h1>
<!-- Paragraph styling with 1.5 line heights & letter spacing -->
<p class="mt-3 leading-loose tracking-wide">
Lorem ipsum dolor sit amet... [trucated]
</p>
<!-- Treated like a quote with a background and plenty of padding. Italic title -->
<div class="m-2 p-6 bg-blue-900 text-blue-200">
<p>
Lorem ipsum dolor sit amet... [truncated]
</p>
<p class="mt-3 text-gray-400">- Victor Gonzalez,
<span class="italic">instructor</span>
</p>
</div>
<!-- Call to action button, blue with good padding and uppercase -->
<button class="uppercase bg-blue-500 text-blue-100 px-4 py-3">Enroll Now</button>
</body>
E09
Borders
ese classes will color, stylize and add radius to any border or corners.
.border {} // 1px
.border-0 {} // 0
.border-2 {} // 2px
.border-4 {} // 4px
.border-8 {} // 8px
// Modifiers
.border-{t, b, l, f}-*
// Colors
.border-{color}-{shade (100-900)}
// Border Style
.border-solid {}
.border-dashed {}
.border-dotted {}
.border-double {}
.border-none {}
// Border Radius
.rounded-none {} // 0
.rounded-sm {} // .125rem
.rounded {} // .25rem
.rounded-lg {} // .5rem
.rounded-full {} // 9999px
E10
Challenge 3 - Button Challenge
Solution
<body>
<!-- blue background, rounded, thick left border -->
<div><button class="m-4 bg-blue-800 py-2 px-4 text-gray-400
text-sm rounded-lg border-l-8 border-blue-700">Submit</button></div>
// Flex Direction
.flex-row {}
.flex-row-reverse {}
.flex-col {}
.flex-col-reverse {}
// Wrapping
.flex-no-wrap {}
.flex-wrap {}
.flex-wrap-reverse {}
E13
Challenge 4 - Block Gallery
Solution
<body>
<!-- Must take up all of the available space -->
<!-- Evenly distributed 3x3 grid -->
<!-- Letters must be centered on the square -->
<!-- Must have some spacing between the blocks -->
<div class="h-screen flex flex-wrap">
<div class="flex w-1/3 h-1/3">
<div class="bg-teal-100 m-2 w-full flex justify-center items-center">A</div>
</div>
<div class="flex w-1/3 h-1/3">
<div class="bg-teal-200 m-2 w-full flex justify-center items-center">B</div>
</div>
<div class="flex w-1/3 h-1/3">
<div class="bg-teal-300 m-2 w-full flex justify-center items-center">C</div>
</div>
<div class="flex w-1/3 h-1/3">
<div class="bg-teal-400 m-2 w-full flex justify-center items-center">D</div>
</div>
<div class="flex w-1/3 h-1/3">
<div class="bg-teal-500 m-2 w-full flex justify-center items-center">E</div>
</div>
<div class="flex w-1/3 h-1/3">
<div class="bg-teal-600 m-2 w-full flex justify-center items-center">F</div>
</div>
<div class="flex w-1/3 h-1/3">
<div class="bg-teal-700 m-2 w-full flex justify-center items-center">G</div>
</div>
<div class="flex w-1/3 h-1/3">
<div class="bg-teal-800 m-2 w-full flex justify-center items-center">H</div>
</div>
<div class="flex w-1/3 h-1/3">
<div class="bg-teal-900 m-2 w-full flex justify-center items-center">I</div>
</div>
</div>
</body>
E14
Responsive Design
All modern applications should be able to responsively t into the screen size. Tailwind is a mobile- rst
framework, meaning that all of the classes that we have talked about thus far, are for mobile and trickle up to
desktop. But we can change this with a couple of modi ers.
// Default breakpoints
[all] // 0px
.sm: // 640px
.md: // 768px
.lg: // 1024px
.xl: // 1280px
// Cursors - responsive
.cursor-{style} // default, pointer, wait, text, move, not-allowed
// Outline - focus
.focus:outline-none // remove default browser outline styling
# use focus:shadow-outline instead for a nicer alternative
<button type="button"
class="block text-gray-500 hover:text-gray-400
focus:text-white focus:outline-none sm:hidden">
<svg class="h-6 w-6 fill-current" viewBox="0 0 24 24">
<path fill-rule="evenodd" d="M4 5h16a1 1 0 0 1 0 2H4a1 1 0 1 1 0-2zm0 6h16a1 1 0 0 1 0 2H4a
</svg>
</button>
</div>
<div class="my-4">
<h1 class="text-2xl text-indigo-100">Want to learn Tailwind CSS?</h1>
<p class="text-sm text-indigo-200">Tailwind is the fastest growing utility-first
CSS framework. Let's learn it step by step.</p>
<div class="relative mt-4 flex justify-between">
<div class="">
<a href="#" class="bg-pink-500
text-indigo-100 font-bold mt-2 px-4
py-2 rounded-full text-xs uppercase">
Enroll Now</a>
</div>
<div class="absolute right-0 bg-white
rounded-full flex justify-center
items-center p-5 border-4
border-pink-500">
<img class="w-16 h-16" src="/images/tailwind-logo.png" />
</div>
</div>
</div>
</div>
</header>
<form class="max-w-xl w-full text-gray-200 mt-4 px-8 md:px-0" action="#" method="post" autocomplete="of
<div class="flex flex-col md:flex-row md:-mx-2">
<label for="first_name" class="sr-only">First name</label>
<input class="bg-gray-700 mt-4 md:mx-2 border
border-gray-600 rounded-lg py-2 px-4 block
w-full md:w-1/2" type="text" placeholder="First name"
id="first_name">
</body>
</html>