About this ebook
Get a rapid introduction to Tailwind, the utility-first CSS framework, and start building sites with it today!
For many years, component-based frameworks, like Bootstrap, were the de facto standard for building websites quickly and easily. But all this magic comes with a price. Without serious customization, sites built with such frameworks look similar to each other. And customization is a real pain in the neck for anyone who wants to build something more complex or creative. Component-based styles are easy to implement, but inflexible and confined to certain boundaries. Solving specificity issues while trying to override the default styles of a particular framework isn't a fun and productive job. Tailwind is a utility-first framework that is built with low-level functionality in mind. As you'll see in this book, utility classes offer much more power and flexibility than component classes. You'll learn:
- Component vs utility classes, and the pros and cons of each
- Tailwind basics (layout, typography, responsive web design, colors, and more)
- Creating your own Tailwind components
- Building complex and flexible layouts with Tailwind's Grid utilities
- Customizing Tailwind
- Working with Tailwind plugins
- And much more!
Ivaylo Gerchev
Ivaylo Gerchev isa web developer/designer from Bulgaria. In his free time he likes to write articles and tutorials sharing his knowledge and understanding on various web development topics. His favorite topics include UI, UX, SVG, HTML, CSS, Tailwind, JavaScript, Node, Nest, Adonis, Vue, React, Angular, PHP, Laravel, and Statamic. The best tools he uses are Figma and VS Code. When he's not programming the Web, he loves to program his own reality.
Read more from Ivaylo Gerchev
Vue.js: 11 Practical Projects Rating: 0 out of 5 stars0 ratingsYour First Week With Bootstrap Rating: 0 out of 5 stars0 ratingsVue.js: Tools & Skills Rating: 0 out of 5 stars0 ratingsLearn Vue.js: The Collection Rating: 0 out of 5 stars0 ratings
Related to Tailwind CSS
Related ebooks
Instant SASS CSS How-to Rating: 5 out of 5 stars5/5Exploring Web Components: Build Reusable UI Web Components with Standard Technologies (English Edition) Rating: 0 out of 5 stars0 ratingsMastering Sass Rating: 0 out of 5 stars0 ratingsGetting SASSY: A Practical Guide to SASS Rating: 0 out of 5 stars0 ratingsJavaScript for Modern Web Development: Building a Web Application Using HTML, CSS, and JavaScript Rating: 0 out of 5 stars0 ratingsModern JavaScript Applications Rating: 0 out of 5 stars0 ratingsResponsive Web Design with HTML5 and CSS3 Rating: 4 out of 5 stars4/5Mastering Responsive Web Design with HTML5 and CSS3 Rating: 0 out of 5 stars0 ratingsProfessional CSS3 Rating: 5 out of 5 stars5/5JavaScript: Tips and Tricks to Programming Code with Javascript: JavaScript Computer Programming, #2 Rating: 0 out of 5 stars0 ratingsHTML5 and CSS3 All-in-One For Dummies Rating: 0 out of 5 stars0 ratingsReact Design Patterns and Best Practices Rating: 0 out of 5 stars0 ratingsResponsive Web Design by Example : Beginner's Guide - Second Edition Rating: 0 out of 5 stars0 ratingsInstant Responsive Web Design Rating: 5 out of 5 stars5/5Sass and Compass for Designers Rating: 0 out of 5 stars0 ratingsMastering Bootstrap 4 Rating: 5 out of 5 stars5/5Responsive Web Design with HTML5 and CSS3 - Second Edition Rating: 4 out of 5 stars4/5Beginner CSS: Like Putting Lipstick on a Zombie: Undead Institute, #2 Rating: 0 out of 5 stars0 ratingsThe Freelance Web Developer: Freelance Jobs and Their Profiles, #17 Rating: 0 out of 5 stars0 ratingsMake Bootstrap Themes Rating: 0 out of 5 stars0 ratings50 Recipes for Programming CSS3 Rating: 0 out of 5 stars0 ratingsUltimate Tailwind CSS Handbook: Build sleek and modern websites with immersive UIs using Tailwind CSS Rating: 0 out of 5 stars0 ratingsNode.JS Guidebook: Comprehensive guide to learn Node.js Rating: 0 out of 5 stars0 ratingsGetting Started with React Rating: 0 out of 5 stars0 ratingsJavaScript: Best Practice Rating: 0 out of 5 stars0 ratingsAdvanced Web Development with React: SSR and PWA with Next.js using React with advanced concepts Rating: 0 out of 5 stars0 ratingsReact Projects: Build 12 real-world applications from scratch using React, React Native, and React 360 Rating: 0 out of 5 stars0 ratingsReact to Python: Creating React Front-End Web Applications with Python Rating: 0 out of 5 stars0 ratingsReact.js Design Patterns: Learn how to build scalable React apps with ease (English Edition) Rating: 0 out of 5 stars0 ratings
Internet & Web For You
The $1,000,000 Web Designer Guide: A Practical Guide for Wealth and Freedom as an Online Freelancer Rating: 4 out of 5 stars4/5Coding For Dummies Rating: 5 out of 5 stars5/5How to Be Invisible: Protect Your Home, Your Children, Your Assets, and Your Life Rating: 4 out of 5 stars4/5Kill All Normies: Online Culture Wars From 4Chan And Tumblr To Trump And The Alt-Right Rating: 3 out of 5 stars3/5Cybersecurity For Dummies Rating: 5 out of 5 stars5/5Coding All-in-One For Dummies Rating: 4 out of 5 stars4/5Python: Learn Python in 24 Hours Rating: 4 out of 5 stars4/5More Porn - Faster!: 50 Tips & Tools for Faster and More Efficient Porn Browsing Rating: 3 out of 5 stars3/548 Really Useful Web Sites Rating: 5 out of 5 stars5/5Tor and the Dark Art of Anonymity Rating: 5 out of 5 stars5/5WordPress For Dummies Rating: 0 out of 5 stars0 ratingsNotion for Beginners: Notion for Work, Play, and Productivity Rating: 4 out of 5 stars4/5The Gothic Novel Collection Rating: 5 out of 5 stars5/5Learn NodeJS in 1 Day: Complete Node JS Guide with Examples Rating: 3 out of 5 stars3/5Beginner's Guide To Starting An Etsy Print-On-Demand Shop Rating: 0 out of 5 stars0 ratingsWeb Design For Dummies Rating: 4 out of 5 stars4/5The Beginner's Affiliate Marketing Blueprint Rating: 4 out of 5 stars4/5Publishing E-Books For Dummies Rating: 4 out of 5 stars4/5Surveillance and Surveillance Detection: A CIA Insider's Guide Rating: 3 out of 5 stars3/5The Digital Marketing Handbook: A Step-By-Step Guide to Creating Websites That Sell Rating: 5 out of 5 stars5/5SEO For Dummies Rating: 4 out of 5 stars4/5No Place to Hide: Edward Snowden, the NSA, and the U.S. Surveillance State Rating: 4 out of 5 stars4/5Content Chemistry: The Illustrated Handbook for Content Marketing Rating: 5 out of 5 stars5/5Everybody Lies: Big Data, New Data, and What the Internet Can Tell Us About Who We Really Are Rating: 4 out of 5 stars4/5How to Disappear and Live Off the Grid: A CIA Insider's Guide Rating: 0 out of 5 stars0 ratingsUltimate guide for being anonymous: Avoiding prison time for fun and profit Rating: 5 out of 5 stars5/5UX/UI Design Playbook Rating: 4 out of 5 stars4/5
Reviews for Tailwind CSS
0 ratings0 reviews
Book preview
Tailwind CSS - Ivaylo Gerchev
Preface
Conventions Used
Code Samples
Code in this book is displayed using a fixed-width font, like so:
A Perfect Summer's Day
It was a lovely day for a walk in the park.
The birds were singing and the kids were all back at school.
You’ll notice that we’ve used certain layout styles throughout this book to signify different types of information. Look out for the following items.
Tips, Notes, and Warnings
Hey, You!
Tips provide helpful little pointers.
Ahem, Excuse Me ...
Notes are useful asides that are related—but not critical—to the topic at hand. Think of them as extra tidbits of information.
Make Sure You Always ...
... pay attention to these important points.
Watch Out!
Warnings highlight any gotchas that are likely to trip you up along the way.
Supplementary Materials
https://www.sitepoint.com/community/ are SitePoint’s forums, for help on any tricky problems.
[email protected] is our email address, should you need to contact us to report a problem, or for any other reason.
Getting Started with Tailwind CSS
There are two main types of CSS framework. One is based around components—a group that includes frameworks such as Bootstrap, Foundation, and Bulma. The other type of CSS framework is based around utilities—a group that includes the likes of Tachyons, Tailwind CSS, and Windi CSS.
Component vs Utility Classes
If you’re not clear on the difference between component and utility classes, jump to the What Is a Utility Class?
section below, and then continue reading from here.
For many years, component-based frameworks were the de facto standard for building websites quickly and easily. But all this magic comes with a price. Without serious customization, sites built with such frameworks look similar to each other. And customization is a real pain in the neck for anyone who wants to build something more complex and/or creative. Component-based styles are easy to implement, but inflexible and confined to certain boundaries. Solving specificity issues while trying to override the default styles of a particular framework isn’t a fun and productive job.
Utility-first
frameworks were created to solve this problem. A utility-first framework is built with low-level functionality in mind. Utility classes offer much more power and flexibility than component classes.
Utility-first frameworks provide the following advantages:
Utility classes operate at a low level. This means we have more control and flexibility over how we apply them—a concept that’s similar to the power and flexibility offered by a low-level language like C or C++, in contrast to high-level languages such as JavaScript or PHP.
Utility classes are easy to customize, so we can build any design.
A utility-first approach scales well. It’s great for managing and maintaining large projects, because we only have to maintain HTML files, instead of a large CSS codebase. It’s already used with success by big sites like GitHub, Heroku, Kickstarter, Twitch, and Segment.
Utility classes can be adopted to any design.
Utility classes are completely customizable and extensible. It’s easier to build unique, custom website designs without fighting with unwanted styles.
Utility classes allow for much easier implementation of responsive design patterns.
Utility classes have consistent styles, which gives us a ready-to-use design system. We can also create our own design system if we need to.
With utility classes, we can still extract common, repetitive patterns into custom, reusable components. But in contrast to predefined components, custom components will be exactly what we need.
In summary, we can say that a utility-first framework gives us balance between the concrete and the abstract.
Now that we’ve seen how useful utility-first frameworks can be, it’s time to pick one and see what it can do for us in action. In this book, we’ll explore Tailwind CSS, which is the most popular of the utility-first frameworks.
What Is Tailwind?
Tailwind is a set of low-level, reusable utility classes that can be used like building blocks to create virtually any design we can imagine. This utility-first framework covers the most important CSS properties, but it can be easily extended in a variety of ways. It can be used either for rapid prototyping or for creating full-blown designs.
Tailwind has great documentation, covering every class utility in detail and showing the ways it can be customized. There’s also a playground where you can try out your ideas. You can also check out Tailwind’s screencasts if you prefer to learn by watching.
As of version 2.0, Tailwind CSS supports the latest stable versions of Chrome, Firefox, Edge, and Safari. There’s no support for any version of IE, including IE11.
What Is a Utility Class?
As we already know, Tailwind’s main characteristic is the use of utility classes. But what is a utility class?
While a component class is a collection of predefined CSS settings applied in an opinionated fashion, a utility class is mostly a single CSS property or behavior that we can use freely in a predictable way. This gives us the freedom to combine, mix and match different settings depending on our requirements. We have greater control over each element’s appearance. We can change and fine-tune an element’s appearance much more effortlessly with utility classes.
In Bootstrap, we create a button by using predefined component classes, as in the following example:
Here, the btn and btn-success are the so-called component classes. Each one of them represents a collection of predefined CSS settings.
In Tailwind, we create a button by using utility