CSS-Trickz!

You probably want CSS-Tricks

The CSS from-font Value Explained in 4 Demos

Written by: Silvestar Bistrović

I was doing my Advent of UI Components, and I stumbled upon the from-font value for the text-decoration-thickness CSS property. I was curious about it, so I did a little research and I think what I found (and learned) is both interesting and worth sharing.

Continue reading "The CSS from-font Value Explained in 4 Demos" at CSS-Tricks

Git: Switching Unstaged Changes to a New Branch

Written by: Chris Coyier

I’m always on the wrong branch. I’m either on master or main working on something that should be on a fix or feature branch. Or I’m on the last branch I was working on and should have cut a new branch. Oh well. It’s never that big of a deal. Basically means switching unstaged changes […]

Continue reading "Git: Switching Unstaged Changes to a New Branch" at CSS-Tricks

Demystifying TypeScript Discriminated Unions

Written by: Adam Rackis

TypeScript is a wonderful tool for writing JavaScript that scales. It’s more or less the de facto standard for the web when it comes to large JavaScript projects. As outstanding as it is, there are some tricky pieces for the unaccustomed. One such area is TypeScript discriminated unions. Specifically, given this code: …many developers are […]

Continue reading "Demystifying TypeScript Discriminated Unions" at CSS-Tricks

Build, Ship, & Maintain Design Systems with Backlight

Written by: Chris Coyier

Design systems are an entire job these days. Agencies are hired to create them. In-house teams are formed to handle them, shipping them so that other teams can use them and helping ensure they do. Design systems aren’t a fad, they are a positive evolution of how digital design is done. Backlight is the ultimate […]

Continue reading "Build, Ship, & Maintain Design Systems with Backlight" at CSS-Tricks

How to Cycle Through Classes on an HTML Element

Written by: Chris Coyier

Say you have three HTML classes, and a DOM element should only have one of them at a time: Now your job is to rotate them. That is, cycle through classes on an HTML element. When some event occurs, if the element has state-1 on it, remove state-1 and add state-2. If it has state-2 […]

Continue reading "How to Cycle Through Classes on an HTML Element" at CSS-Tricks

Fancy CSS Borders Using Masks

Written by: Temani Afif

Have you ever tried to make CSS borders in a repeating zig-zag pattern? Like where a colored section of a website ends and another differently colored section begins — not with a straight line, but angled zig zags, rounded humps, or waves. There are a number of ways you could do this sort of CSS […]

Continue reading "Fancy CSS Borders Using Masks" at CSS-Tricks

How Do You Handle Component Spacing in a Design System?

Written by: Chris Coyier

Say you’ve got a <Card /> component. It’s highly likely it shouldn’t be butted right up against any other components with no spacing around it. That’s true for… pretty much every component. So, how do you handle component spacing in a design system? Do you apply spacing using margin directly on the <Card />? Perhaps […]

Continue reading "How Do You Handle Component Spacing in a Design System?" at CSS-Tricks

How to Make a Scroll-Triggered Animation With Basic JavaScript

Written by: Md Shuvo

A little bit of animation on a site can add some flair, impress users, and get their attention. You could have them run, no matter where they are on the page, immediately when the page loads. But what if your website is fairly long so it took some time for the user to scroll down […]

Continue reading "How to Make a Scroll-Triggered Animation With Basic JavaScript" at CSS-Tricks

Why Don’t Developers Take Accessibility Seriously?

Written by: Melanie Sumner

You know that joke, “Two front-end developers walk into a bar and find they have nothing in common”? It’s funny, yet frustrating, because it’s true. This article will present three different perspectives on accessibility in web design and development. Three perspectives that could help us bridge the great divide between users and designers/developers. It might […]

Continue reading "Why Don’t Developers Take Accessibility Seriously?" at CSS-Tricks

Using SVG in WordPress (2 Helpful Plugin Recommendations)

Written by: Chris Coyier

SVG is a great image format, so it’s nice to able to use it in WordPress. If you’re looking to be using SVG in WordPress. , we’ve got you covered here with all the best options.

Continue reading "Using SVG in WordPress (2 Helpful Plugin Recommendations)" at CSS-Tricks

Context-Aware Web Components Are Easier Than You Think

Written by: John Rhea

Another aspect of web components that we haven’t talked about yet is that a JavaScript function is called whenever a web component is added or removed from a page. These lifecycle callbacks can be used for many things, including making an element aware of its context.

Continue reading "Context-Aware Web Components Are Easier Than You Think" at CSS-Tricks

A Complete Beginner’s Guide to npm

Written by: Josh Collinsworth

I remember vividly a period early in my coding career when I began to feel that things were changing away from what I knew, and headed towards a more complex set of tools and practices, anchored in the command line and something called npm. This is the first part of a beginner’s guide where we […]

Continue reading "A Complete Beginner’s Guide to npm" at CSS-Tricks