Auditing
- CSS Auditing Tools • Smashing Magazine 📖
Grid
- Learn CSS Grid for free • Scrimba 🎓
- Become a CSS Grid wizard with grid-template-areas • Builder.io 📖
- An Interactive Guide to CSS Grid • Josh Comeau 📖
Layout
- Every Layout • A collection of CSS layout patterns by Heydon Pickering and Andy Bell 📚
- 10 modern layouts in 1 line of CSS • Una Kravets 📺
- What the heck, z-index?? • Josh Comeau explains stacking contexts 📖
- Finally, CSS margin-trim! • Wes Bos is 📺
- Responsive Design and Composition • Avoid complicated breakpoint conditionals by simply swapping between two separate components when their layouts diverge enough • Kyle Shevlin 📚
Utility-First CSS
- Why?
- Overall, MUCH FASTER than any other approach
- Less repetition since each possible css declaration is written once and then reused = faster
- On each new project, you write less and less css since all old utilities can be reused = faster, fewer chances for errors
- No context switching (since all HTML and css info is in one place) = faster, less mental fatigue
- Prototyping is FAST and the classes do NOT need to be removed later
- Repeated groups of class names can be grouped with @apply to avoid repeating class clusters
- Equal specificity = the classes you add always work
- Less typing = faster, fewer errors
- When you come back later and want to tweak something, you can see and make all your changes in one place (instead of hunting through other files to figure out what css is applied, what the HTML elements are, etc)
- Why a good fit for React (and other component-based JS frameworks):
- React’s component-based model means you are already thinking in terms of small, reusable building blocks
- utility-first css classes are basically CSS building blocks
- functional (each class is basically a well-named function that gives you exactly what you think it will; small enough to be maximally reusable and non-conflicting)
- component-based
- the concern over verbose className attributes is solved by the fact that they are only listed in one place (the component)
- reusability can also be achieved with Tailwinds’ @apply directive
- benefits: you don’t have to write CSS, you just use CSS that’s already been written; you don’t have to switch between files to see the relationship between the semantics and styling, which helps you reason about your UI and how to tweak it much more quickly and easily and without the concentration fatigue that builds up with context-switching; rapid prototyping and iteration is possible because you are applying classes 1 second after creating the markup and can make visual changes as quickly as you can think of them - much faster than moving elsewhere in the file (or switching) files to update a CSS declaration; faster styling by typing fewer characters (e.g. ‘bg-blue’ instead of ‘background-colour: blue’), makes a huge difference over time to type fewer characters in a closer location
- Tools: Tachyons, Tailwind CSS, Custom with Tailwinds as generator
- Further reading: @mrmrs original post, Simon Swiss’ 4-part Tachyons blog series, Egghead course and recent presentations
- Concept:
- CSS Utility Classes and “Separation of Concerns” • Adam Wathan 📖
- Designing with code • Matthew Ström 📖
- Tailwind CSS:
- Building a Twitter Clone with Tailwind CSS and Next.js • Sam Selikoff 📺
- Tailwind CSS Tips, Tricks & Best Practices • Sam Selikoff 📺
- Tailwind CSS Best Practice Patterns • Adam Wathan 📺
- Atomic CSS-in-JS • Sébastien Lorber 📖
- Other libraries:
- UnoCSS: The instant on-demand Atomic CSS engine • A new utility-first CSS library 🛠️
Media Queries (beyond just width)
- “Do you know about the pointer media query? It lets you detect whether a screen is primarily touch-based…” • Lea Verou 🐦
Container Queries
- CSS Container Queries are here! • Wes Bos 📺
Logical Properties
- CSS Logical Properties and Values • MDN 📚
- Digging Into CSS Logical Properties • Ahmad Shadeed 📖
- A Complete Guide to CSS Functions • Eric Bailey 📖
- min(), max(), and clamp() CSS Functions • Ahmad Shadeed 📖
- “I’m in love with the CSS
clamp
function. It lets you clamp a value between a min and max, across units…” • Josh Comeau 🐦- beware of using vw/vh for font sizes because they don’t increase when zooming (bad a11y)
Styling Scrollbars
- Two Browsers Walked Into a Scrollbar • Zach Leatherman explains how to style scrollbars 📖
Fonts
- Modern Font Stacks • System font stack CSS organized by typeface classification for every modern OS. The fastest fonts available. No downloading, no layout shifts, no flashes — just instant renders. 📚
Design systems
- Create your design system, part 4: Spacing • Sebastiano Guerriero 📖
Scroll-driven animations
- Solved by CSS Scroll-Driven Animations: Detect if an element can scroll or not • Leverage Scroll-Driven Animations + a Space Toggle or State Query to selectively style an element based on it being scrollable or not • Bramus Van Damme 📖
Other syntax
line-height
values should be unitless- “Taken a bit, but I’m enjoying using *-inline and *-block properties instead of Top/Right/Bottom/Left properties…” • Wes Bos 🐦
- The Future of CSS: Cascade Layers (CSS @layer) • Bramus Van Damme 📖
- A table with both a sticky header and a sticky first column • Chris Coyier 📖
Accessibility
- What Happened To Text Inputs? • A critique of styling choices that make text inputs more confusing to use • Heydon Pickering 📺
How to make text readable
- Bump up base font size on large screens
- Use line height
- Use max width (in characters)
What Input?
- tracks your user’s input mode and records it in data attributes added to the
window
- to hide outlines except for keyboard users, you just need one CSS declaration:
[data-whatintent='mouse'] *:focus,
[data-whatintent='touch'] *:focus,
html:not([data-whatinput='keyboard']) *:focus {
outline: none;
}
Links:
- what-input • A global utility for tracking the current input method (mouse, keyboard or touch) 🛠️
Icons
- Flaticons • Free vector icons and stickers in PNG, SVG, EPS, PSD and CSS 🛠️
Forms
- :user-invalid Pseudo Selector • How to avoid styling an input as invalid until a user has interacted with it • Wes Bos 📺
Inbox
-
CSS tips series?
-
How To Improve Lighthouse Scores by Avoiding <img> Layout Shifts • add something like
aspect-ratio: 16 / 9; width: 100%; background-color: gray
toimg
tags to avoid CLS when the image loads • Builder.io 📖 -
CSS Tips for Better Web Development • Builder.io 📖
-
TypeSafe Tailwind // Compile time validation for tailwind classes • Combine with CSS Modules • basarat 📺
-
Tailwind “Minimum Full Height” Layout | Kyle Shevlin • Quick summary of a very useful pattern • Kyle Shevlin 📖