# css variables

Published articles for css variables.

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## CSS Variables: How to Use Custom Properties

DevFeed: [CSS Variables: How to Use Custom Properties](<https://devfeed.tech/articles/css-variables-how-to-use-custom-properties-148080.md>)

Original publisher: [Read original article](<https://markodenic.com/css-variables/>)

Author: Marko

Published: 2026-11-22T09:00:00Z

Content type: article

Language: en

Sources: [Marko Denic Blog](<https://devfeed.tech/sources/marko-denic-blog.md>)

Topics: [CSS](<https://devfeed.tech/topics/css.md>), [Web Development](<https://devfeed.tech/topics/web-development.md>), [Front end](<https://devfeed.tech/topics/frontend.md>)

Tags: [css](<https://devfeed.tech/tags/css.md>), [css-variables](<https://devfeed.tech/tags/css-variables.md>), [custom-properties](<https://devfeed.tech/tags/custom-properties.md>), [gotchas](<https://devfeed.tech/tags/gotchas.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [inheritance](<https://devfeed.tech/tags/inheritance.md>), [javascript](<https://devfeed.tech/tags/javascript.md>), [scope](<https://devfeed.tech/tags/scope.md>), [syntax](<https://devfeed.tech/tags/syntax.md>), [tutorial](<https://devfeed.tech/tags/tutorial.md>), [var](<https://devfeed.tech/tags/var.md>)

### AI overview

CSS custom properties are declared with `--name` and read with `var()`. They inherit through the DOM, can be overridden on a wrapper to restyle a subtree, and can power themes by swapping values on a class or attribute. JavaScript reads them with `getComputedStyle()` and changes them with `setProperty()`; setting a value on the root affects the page. `var()` fallbacks apply when a variable is missing, not when its value is invalid for the consuming property, which then becomes unset. Variables work in property values, not selectors or media query conditions; `calc()` can attach units to unitless values. Registering a property with `@property` supplies its type, initial value, and inheritance behavior, enabling transitions and animation; the excerpt lists support from Chrome 85, Safari 16.4, and Firefox 128.

### Source excerpt

How CSS variables work: syntax, var() fallbacks, scope and inheritance, theming, changing them with JavaScript, @property, and the gotchas that break them.

## true or false in CSS

DevFeed: [true or false in CSS](<https://devfeed.tech/articles/true-or-false-in-css-121945.md>)

Original publisher: [Read original article](<https://blog.master.dev/true-or-false-in-css/>)

Author: Preethi Sam

Published: 2026-11-06T13:38:19Z

Content type: article

Language: en

Sources: [Master.dev Blog RSS Feed](<https://devfeed.tech/sources/master-dev-blog-rss-feed.md>)

Topics: [CSS](<https://devfeed.tech/topics/css.md>), [selectors](<https://devfeed.tech/topics/selectors.md>), [data type](<https://devfeed.tech/topics/data-type.md>), [Front end](<https://devfeed.tech/topics/frontend.md>), [typesafety](<https://devfeed.tech/topics/typesafety.md>), [Web Development](<https://devfeed.tech/topics/web-development.md>)

Tags: [blog-post](<https://devfeed.tech/tags/blog-post.md>), [boolean](<https://devfeed.tech/tags/boolean.md>), [boolean-type](<https://devfeed.tech/tags/boolean-type.md>), [conditional](<https://devfeed.tech/tags/conditional.md>), [container-queries](<https://devfeed.tech/tags/container-queries.md>), [css](<https://devfeed.tech/tags/css.md>), [css-custom-properties](<https://devfeed.tech/tags/css-custom-properties.md>), [css-variables](<https://devfeed.tech/tags/css-variables.md>), [custom-properties](<https://devfeed.tech/tags/custom-properties.md>), [data-type](<https://devfeed.tech/tags/data-type.md>), [has](<https://devfeed.tech/tags/has.md>), [html](<https://devfeed.tech/tags/html.md>), [inheritance](<https://devfeed.tech/tags/inheritance.md>), [logic](<https://devfeed.tech/tags/logic.md>), [performance](<https://devfeed.tech/tags/performance.md>), [property](<https://devfeed.tech/tags/property.md>), [scope](<https://devfeed.tech/tags/scope.md>), [style-queries](<https://devfeed.tech/tags/style-queries.md>)

### AI overview

CSS has no native boolean data type, but registered custom properties can emulate true/false flags for conditional styling. The excerpt registers `--isBackpack` and `--isDuffel` with syntax `"true | false"`, defaults them to `false`, and disables inheritance. `:has()` sets each flag on `:root` when its checkbox is checked; a named root container then exposes those values to style queries. The example uses `@container` conditions to hide products outside the selected categories, including the combined checkbox state. This replaces long checked/unchecked selector combinations with readable conditions. Registration is recommended in the excerpt for type safety, performance, and avoiding inheritance; a root container name is unnecessary when the queried property is on the direct parent or is inheritable.

### Source excerpt

CSS doesn't have a boolean type, but it does have the true and false keywords. Register a custom property that only accepts them, flip it with :has(), and container style queries turn messy :checked selector combinations into readable conditions.

## Introducing Adaptive Dark Mode

DevFeed: [Introducing Adaptive Dark Mode](<https://devfeed.tech/articles/introducing-adaptive-dark-mode-116294.md>)

Original publisher: [Read original article](<https://webkit.org/blog/18541/introducing-adaptive-dark-mode/>)

Author: Simon Fraser; Luming Yin; Lily Spiniolas; Joanne Pan; Veda Periwal; Jen Simmons

Published: 2026-11-03T18:00:35Z

Content type: release

Language: en

Sources: [WebKit](<https://devfeed.tech/sources/webkit.md>)

Topics: [Dark Mode](<https://devfeed.tech/topics/dark-mode.md>), [Web Development](<https://devfeed.tech/topics/web-development.md>), [CSS](<https://devfeed.tech/topics/css.md>), [Web Accessibility (a11y)](<https://devfeed.tech/topics/web-accessibility.md>)

Tags: [2019](<https://devfeed.tech/tags/2019.md>), [adaptive-dark-mode](<https://devfeed.tech/tags/adaptive-dark-mode.md>), [appearance](<https://devfeed.tech/tags/appearance.md>), [apple](<https://devfeed.tech/tags/apple.md>), [beta](<https://devfeed.tech/tags/beta.md>), [browser](<https://devfeed.tech/tags/browser.md>), [canvas](<https://devfeed.tech/tags/canvas.md>), [canvases](<https://devfeed.tech/tags/canvases.md>), [color](<https://devfeed.tech/tags/color.md>), [colors](<https://devfeed.tech/tags/colors.md>), [content](<https://devfeed.tech/tags/content.md>), [creative](<https://devfeed.tech/tags/creative.md>), [css](<https://devfeed.tech/tags/css.md>), [css-functions](<https://devfeed.tech/tags/css-functions.md>), [css-gradients](<https://devfeed.tech/tags/css-gradients.md>), [css-variables](<https://devfeed.tech/tags/css-variables.md>), [dark-mode](<https://devfeed.tech/tags/dark-mode.md>), [development-practices](<https://devfeed.tech/tags/development-practices.md>), [element](<https://devfeed.tech/tags/element.md>), [news](<https://devfeed.tech/tags/news.md>), [safari](<https://devfeed.tech/tags/safari.md>)

### AI overview

Safari 27.3 beta's Adaptive Dark Mode can turn bright websites dark when a user with system appearance set to dark enables it. Safari leaves pages that declare `color-scheme: light dark` alone; otherwise it estimates whether a page is light or dark and transforms light pages. Its color matrix darkens light backgrounds and lightens text while preserving hue and aiming for WCAG 4.5:1 text contrast. Most images and all `<canvas>` content remain unchanged; Safari may adjust SVG colors and simple black-and-white bitmap logos, and may disable masks or `mix-blend-mode` effects on transformed elements. Site owners can improve results with modern CSS and SVG assets, add custom dark styles using `color-scheme: light dark`, or declare full dark-mode support early in HTML or CSS. The `light only` opt-out is described, but its `only` keyword is not supported in Safari 27.3 beta 1. Websites cannot detect applied transformations: JavaScript color queries and canvas draw operations expose original authored colors and images.

### Source excerpt

We're excited to announce Adaptive Dark Mode in Safari 27.3 beta.

## Dark Mode CSS Variables: Build a Modern Theme with light-dark()

DevFeed: [Dark Mode CSS Variables: Build a Modern Theme with light-dark()](<https://devfeed.tech/articles/dark-mode-css-variables-build-a-modern-theme-with-light-dark-87793.md>)

Original publisher: [Read original article](<https://www.sitepoint.com/dark-mode-css-variables-light-dark/>)

Author: SitePoint Team

Published: 2026-10-15T16:01:42Z

Content type: tutorial

Language: en

Sources: [SitePoint](<https://devfeed.tech/sources/sitepoint.md>)

Topics: [Dark Mode](<https://devfeed.tech/topics/dark-mode.md>), [CSS](<https://devfeed.tech/topics/css.md>)

Tags: [css](<https://devfeed.tech/tags/css.md>), [css-variables](<https://devfeed.tech/tags/css-variables.md>), [dark-mode](<https://devfeed.tech/tags/dark-mode.md>), [dark-mode-toggle](<https://devfeed.tech/tags/dark-mode-toggle.md>), [design-ux](<https://devfeed.tech/tags/design-ux.md>), [fallback](<https://devfeed.tech/tags/fallback.md>), [html-css](<https://devfeed.tech/tags/html-css.md>), [javascript](<https://devfeed.tech/tags/javascript.md>), [js](<https://devfeed.tech/tags/js.md>)

### AI overview

This tutorial explains how to build a framework-free dark mode toggle using CSS custom properties, `color-scheme`, and `light-dark()`. It covers a three-state system, saving the user's preference in `localStorage`, preventing a flash of the wrong theme during page load, and a `prefers-color-scheme` fallback for browsers without `light-dark()` support.

### Source excerpt

Build a no-flash dark mode toggle with plain CSS and JS. Use color-scheme, light-dark() and CSS variables, persist the choice in localStorage, and add a fallback. Continue reading Dark Mode CSS Variables: Build a Modern Theme with light-dark() on SitePoint.

## CSS calc(): How to Do Math in CSS (With Examples)

DevFeed: [CSS calc(): How to Do Math in CSS (With Examples)](<https://devfeed.tech/articles/css-calc-how-to-do-math-in-css-with-examples-66740.md>)

Original publisher: [Read original article](<https://markodenic.com/css-calc/>)

Author: Marko

Published: 2026-10-07T17:24:50Z

Content type: tutorial

Language: en

Sources: [Marko Denic Blog](<https://devfeed.tech/sources/marko-denic-blog.md>)

Topics: [CSS](<https://devfeed.tech/topics/css.md>), [Web Development](<https://devfeed.tech/topics/web-development.md>)

Tags: [browser](<https://devfeed.tech/tags/browser.md>), [browsers](<https://devfeed.tech/tags/browsers.md>), [calc](<https://devfeed.tech/tags/calc.md>), [clamp](<https://devfeed.tech/tags/clamp.md>), [css](<https://devfeed.tech/tags/css.md>), [css-variables](<https://devfeed.tech/tags/css-variables.md>), [devtools](<https://devfeed.tech/tags/devtools.md>), [examples](<https://devfeed.tech/tags/examples.md>), [flexbox](<https://devfeed.tech/tags/flexbox.md>), [grid](<https://devfeed.tech/tags/grid.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [layouts](<https://devfeed.tech/tags/layouts.md>), [tutorial](<https://devfeed.tech/tags/tutorial.md>), [units](<https://devfeed.tech/tags/units.md>), [web-development](<https://devfeed.tech/tags/web-development.md>)

### AI overview

This tutorial explains CSS calc() syntax, how it combines values and units, and how to use it in layouts, fluid typography, and custom-property calculations. It covers common invalid expressions, debugging with DevTools, and when to use min(), max(), or clamp().

### Source excerpt

How the CSS calc() function works: syntax, mixing units, full-height layouts, equal columns, CSS variables, clamp() and the common mistakes. With a live demo.

## Build-Time Syntax Highlighting With Shiki and Rehype

DevFeed: [Build-Time Syntax Highlighting With Shiki and Rehype](<https://devfeed.tech/articles/build-time-syntax-highlighting-with-shiki-and-rehype-59347.md>)

Original publisher: [Read original article](<https://hackernoon.com/build-time-syntax-highlighting-with-shiki-and-rehype?source=rss>)

Author: Lucas Tonelli

Published: 2026-09-24T09:30:11Z

Content type: tutorial

Language: en

Sources: [HackerNoon](<https://devfeed.tech/sources/hackernoon.md>)

Topics: [Syntax Highlighting](<https://devfeed.tech/topics/syntax-highlighting.md>), [build performance](<https://devfeed.tech/topics/build-performance.md>), [Web Development](<https://devfeed.tech/topics/web-development.md>), [Code](<https://devfeed.tech/topics/code.md>), [HTML](<https://devfeed.tech/topics/html.md>), [Markdown](<https://devfeed.tech/topics/markdown.md>)

Tags: [build](<https://devfeed.tech/tags/build.md>), [build-time-rendering](<https://devfeed.tech/tags/build-time-rendering.md>), [code](<https://devfeed.tech/tags/code.md>), [css-variables](<https://devfeed.tech/tags/css-variables.md>), [highlighting](<https://devfeed.tech/tags/highlighting.md>), [html](<https://devfeed.tech/tags/html.md>), [markdown](<https://devfeed.tech/tags/markdown.md>), [markdown-processing](<https://devfeed.tech/tags/markdown-processing.md>), [nodejs](<https://devfeed.tech/tags/nodejs.md>), [rehype](<https://devfeed.tech/tags/rehype.md>), [shikijs](<https://devfeed.tech/tags/shikijs.md>), [static-site-generation](<https://devfeed.tech/tags/static-site-generation.md>), [syntax-highlighting](<https://devfeed.tech/tags/syntax-highlighting.md>), [textmate-grammars](<https://devfeed.tech/tags/textmate-grammars.md>), [unifiedjs](<https://devfeed.tech/tags/unifiedjs.md>)

### AI overview

A tutorial on using Shiki and rehype to perform syntax highlighting at build time for Markdown, HTML, and inline code. It explains how highlighting can be generated into static HTML, how the rehype plugin integrates with syntax trees, and how themes, imports, and inline-code handling work.

### Source excerpt

Use Shiki and rehype to highlight Markdown, HTML, and inline code at build time without shipping a syntax-highlighting library to the browser.

## Managing Custom Spacing Between Flexbox and Grid Items with CSS

DevFeed: [Managing Custom Spacing Between Flexbox and Grid Items with CSS](<https://devfeed.tech/articles/self-gap-45378.md>)

Original publisher: [Read original article](<https://ishadeed.com/article/self-gap/>)

Author: Ahmad Shadeed

Published: 2025-03-18T00:00:00Z

Content type: tutorial

Language: en

Sources: [Ahmad Shadeed](<https://devfeed.tech/sources/ahmad-shadeed.md>)

Topics: [CSS](<https://devfeed.tech/topics/css.md>), [layout](<https://devfeed.tech/topics/layout.md>), [Web Development](<https://devfeed.tech/topics/web-development.md>)

Tags: [container](<https://devfeed.tech/tags/container.md>), [css](<https://devfeed.tech/tags/css.md>), [css-variables](<https://devfeed.tech/tags/css-variables.md>), [flexbox](<https://devfeed.tech/tags/flexbox.md>), [grid](<https://devfeed.tech/tags/grid.md>), [layout](<https://devfeed.tech/tags/layout.md>), [margins](<https://devfeed.tech/tags/margins.md>), [spacing](<https://devfeed.tech/tags/spacing.md>)

### AI overview

This tutorial examines ways to create custom spacing between flexbox or grid items. It compares margins, nested containers, and the default flow layout, then demonstrates using CSS variables with a flow utility.

### Source excerpt

Thinking of a way to have a custom gap between some flex or grid items.

## Recreating a custom dashboard in Omni

DevFeed: [Recreating a custom dashboard in Omni](<https://devfeed.tech/articles/recreating-a-custom-dashboard-in-omni-82587.md>)

Original publisher: [Read original article](<https://omni.co/blog/recreating-a-custom-dashboard-in-omni>)

Author: Sarah Waterson

Published: 2025-02-19T16:00:00Z

Content type: tutorial

Language: en

Sources: [Omni Blog](<https://devfeed.tech/sources/omni-blog.md>)

Topics: [dashboards](<https://devfeed.tech/topics/dashboards.md>), [User interface design](<https://devfeed.tech/topics/ui-design.md>), [Handlebars](<https://devfeed.tech/topics/handlebars.md>), [Dark Mode](<https://devfeed.tech/topics/dark-mode.md>)

Tags: [css](<https://devfeed.tech/tags/css.md>), [css-variables](<https://devfeed.tech/tags/css-variables.md>), [custom-dashboard](<https://devfeed.tech/tags/custom-dashboard.md>), [custom-dashboard-markdown](<https://devfeed.tech/tags/custom-dashboard-markdown.md>), [dark-mode](<https://devfeed.tech/tags/dark-mode.md>), [dashboard](<https://devfeed.tech/tags/dashboard.md>), [observable](<https://devfeed.tech/tags/observable.md>)

### AI overview

The article walks through recreating a mortgage-rate dashboard in Omni using eCommerce data. It covers time-series charts, calculated summary cards built with HTML and CSS in markdown visualizations, and theme adjustments, including limitations and workarounds for customization and light and dark mode.

### Source excerpt

Recently, my colleague Trevor shared a mortgage rate demo dashboard from Observable that one of our customers liked for its visualizations, interactions, and design details. I was inspired to recreate it in Omni and here is how I approached it.

## Tailwind CSS v4.0

DevFeed: [Tailwind CSS v4.0](<https://devfeed.tech/articles/tailwind-css-v4-0-3499.md>)

Original publisher: [Read original article](<https://tailwindcss.com/blog/tailwindcss-v4>)

Published: 2025-01-22T22:00:00Z

Content type: release

Language: en

Sources: [Tailwind CSS](<https://devfeed.tech/sources/tailwind-css-blog.md>)

Topics: [Tailwind CSS](<https://devfeed.tech/topics/tailwind.md>), [CSS](<https://devfeed.tech/topics/css.md>), [performance-optimization](<https://devfeed.tech/topics/performance-optimization.md>)

Tags: [3d](<https://devfeed.tech/tags/3d.md>), [apis](<https://devfeed.tech/tags/apis.md>), [automatic](<https://devfeed.tech/tags/automatic.md>), [automatically](<https://devfeed.tech/tags/automatically.md>), [browser](<https://devfeed.tech/tags/browser.md>), [configuration](<https://devfeed.tech/tags/configuration.md>), [container](<https://devfeed.tech/tags/container.md>), [css](<https://devfeed.tech/tags/css.md>), [css-variables](<https://devfeed.tech/tags/css-variables.md>), [customization](<https://devfeed.tech/tags/customization.md>), [framework](<https://devfeed.tech/tags/framework.md>), [gradient](<https://devfeed.tech/tags/gradient.md>), [installation](<https://devfeed.tech/tags/installation.md>), [performance](<https://devfeed.tech/tags/performance.md>), [tailwind](<https://devfeed.tech/tags/tailwind.md>), [tailwind-css](<https://devfeed.tech/tags/tailwind-css.md>), [web-platform](<https://devfeed.tech/tags/web-platform.md>)

### AI overview

Tailwind CSS v4.0 introduces a faster engine, with full builds reported up to 5x faster and incremental builds over 100x faster. The release shifts configuration and customization into CSS, exposes design tokens as native CSS variables, and simplifies setup with fewer dependencies, zero configuration, automatic content detection, built-in imports, and a first-party Vite plugin. Highlighted additions include container queries without plugins, 3D transforms, expanded gradients, and an @starting-style variant for transitions without JavaScript. The excerpt also mentions an automated upgrade tool and upgrade guide for existing projects.

### Source excerpt

We just released Tailwind CSS v4.0 -- an all-new version of the framework optimized for performance and flexibility, with a reimagined configuration and customization experience, and taking full advantage of the latest advancements the web platform has to offer.

## Design Engineering an X Component

DevFeed: [Design Engineering an X Component](<https://devfeed.tech/articles/design-engineering-an-x-component-82675.md>)

Original publisher: [Read original article](<https://resend.com/blog/design-engineering-an-x-component>)

Author: Danilo Woznica

Published: 2024-12-11T00:00:00Z

Content type: article

Language: en

Sources: [Resend](<https://devfeed.tech/sources/resend.md>)

Topics: [User interface design](<https://devfeed.tech/topics/ui-design.md>), [Dark Mode](<https://devfeed.tech/topics/dark-mode.md>), [CI/CD](<https://devfeed.tech/topics/cicd.md>), [Mantine](<https://devfeed.tech/topics/mantine.md>)

Tags: [api](<https://devfeed.tech/tags/api.md>), [code](<https://devfeed.tech/tags/code.md>), [css](<https://devfeed.tech/tags/css.md>), [css-variables](<https://devfeed.tech/tags/css-variables.md>), [design-engineering](<https://devfeed.tech/tags/design-engineering.md>), [engineering](<https://devfeed.tech/tags/engineering.md>), [x](<https://devfeed.tech/tags/x.md>)

### AI overview

The article describes how a design engineer built an X post component for the Broadcasts email editor. Because email-safe HTML cannot embed a dynamic post, the implementation creates a static image from post data with Next.js ImageResponse and stores it for use in email. It also covers image sizing, Satori's HTML and CSS limits, theme support, and visual edge cases.

### Source excerpt

We recently added a new component to Broadcasts. Here's a behind-the-scenes look at the technical process.

## Inline conditionals in CSS, now?

DevFeed: [Inline conditionals in CSS, now?](<https://devfeed.tech/articles/inline-conditionals-in-css-now-52157.md>)

Original publisher: [Read original article](<https://lea.verou.me/blog/2024/css-conditionals-now/>)

Author: Lea Verou

Published: 2024-06-21T00:00:00Z

Content type: opinion

Language: en

Sources: [Lea Verou's blog](<https://devfeed.tech/sources/lea-verou-s-blog.md>)

Topics: [conditionals](<https://devfeed.tech/topics/conditionals.md>), [CSS](<https://devfeed.tech/topics/css.md>), [Web platform](<https://devfeed.tech/topics/web-platform.md>), [web-standards](<https://devfeed.tech/topics/web-standards.md>), [abstraction](<https://devfeed.tech/topics/abstraction.md>), [Vue.js](<https://devfeed.tech/topics/vue.md>)

Tags: [blog](<https://devfeed.tech/tags/blog.md>), [conditionals](<https://devfeed.tech/tags/conditionals.md>), [css](<https://devfeed.tech/tags/css.md>), [css-variables](<https://devfeed.tech/tags/css-variables.md>), [css-wg](<https://devfeed.tech/tags/css-wg.md>), [developers](<https://devfeed.tech/tags/developers.md>), [vue](<https://devfeed.tech/tags/vue.md>), [web-components](<https://devfeed.tech/tags/web-components.md>), [web-platform](<https://devfeed.tech/tags/web-platform.md>)

### AI overview

The article examines the gap between the CSS Working Group's planned if() function and current browser support. It presents custom-property hacks as interim options and argues that production decisions should prioritize user needs over developer convenience, drawing on Web Platform Design Principles and the Priority of Constituencies.

### Source excerpt

The CSS WG resolved to add if() to CSS, but that won't be in browsers for a while. What are our options in the meantime? A couple days ago, I posted about the recent CSS WG resolution to add an if() function to CSS. Great as it may be, this is still a long way off, two years if everything goes super smoothly, more if not. So what can you do when you need conditionals right now? You may be pleased to find that you're not completely out of luck. There is a series of brilliant, horrible hacks that enable you to expose the kinds of higher level custom properties that conditionals typically enable. Using hacks in production?! The instinctive reaction many developers have when seeing hacks like these is "Nice hack, but can't possibly ever use this in production". This sounds reasonable on the surface (keeping the codebase maintainable is a worthy goal!) but when examined deeply, it reflects the wrong order of priorities, prioritizing developer convenience over user convenience. The TAG maintains a Web Platform Design Principles document 1 that everyone designing APIs for the web platform is supposed to read and follow. I'm a strong believer in having published Design Principles, for any product2. They help stay on track, and remember what the big picture vision is, which is otherwise easy to lose sight of in the day to day minutiae. One of the core principles in the document is the Priority of Constituencies. The core of it is: User needs come before the needs of web page authors, which come before the needs of user agent implementors, which come before the needs of specification writers, which come before theoretical purity. Obviously in most projects there are far fewer stakeholders than for the whole web platform, but the spirit of the principle still applies: the higher the abstraction, the higher priority the user needs. Or, in other words, consumers above producers. For a more relatable example, in a web app using a framework like e.g. Vue and several Vue components

## Inline conditionals in CSS?

DevFeed: [Inline conditionals in CSS?](<https://devfeed.tech/articles/inline-conditionals-in-css-52158.md>)

Original publisher: [Read original article](<https://lea.verou.me/blog/2024/css-conditionals/>)

Author: Lea Verou

Published: 2024-06-18T00:00:00Z

Content type: article

Language: en

Sources: [Lea Verou's blog](<https://devfeed.tech/sources/lea-verou-s-blog.md>)

Topics: [CSS](<https://devfeed.tech/topics/css.md>), [conditionals](<https://devfeed.tech/topics/conditionals.md>), [Web Development](<https://devfeed.tech/topics/web-development.md>), [browser](<https://devfeed.tech/topics/browser.md>)

Tags: [blog](<https://devfeed.tech/tags/blog.md>), [conditionals](<https://devfeed.tech/tags/conditionals.md>), [css](<https://devfeed.tech/tags/css.md>), [css-variables](<https://devfeed.tech/tags/css-variables.md>), [css-wg](<https://devfeed.tech/tags/css-wg.md>), [developers](<https://devfeed.tech/tags/developers.md>), [iteration](<https://devfeed.tech/tags/iteration.md>), [roadmaps](<https://devfeed.tech/tags/roadmaps.md>), [web-components](<https://devfeed.tech/tags/web-components.md>), [web-standards](<https://devfeed.tech/tags/web-standards.md>)

### AI overview

The article discusses the CSS Working Group's consensus to add an inline if() conditional syntax to CSS. It explains the proposal's motivation, relationship to style queries, and path through earlier rejected proposals.

### Source excerpt

Last week, the CSS WG resolved to add an inline if() to CSS. But what does that mean, and why is it exciting? Last week, we had a CSS WG face-to-face meeting in A Coruña, Spain. There is one resolution from that meeting that I'm particularly excited about: the consensus to add an inline if() to CSS. While I was not the first to propose an inline conditional syntax, I did try and scope down the various nonterminating discussions into an MVP that can actually be implemented quickly, discussed ideas with implemenators, and eventually published a concrete proposal and pushed for group resolution. Quite poetically, the relevant discussion occurred on my birthday, so in a way, I got if() as the most unique birthday present ever. 😀 This also comes to show that proposals being rejected is not the end-all for a given feature. It is in fact quite common for features to be rejected for several times before they are accepted: CSS Nesting, :has(), container queries were all simply the last iteration in a series of rejected proposals. if() itself was apparently rejected in 2018 with very similar syntax to what I proposed. What was the difference? Style queries had already shipped, and we could simply reference the same syntax for conditions (plus media() and supports() from Tab's @when proposal) whereas in the 2018 proposal how conditions would work was largely undefined. I posted about this on a variety of social media, and the response by developers has been overwhelmingly positive: Twitter LinkedIn Mastodon I even had friends from big companies writing to tell me their internal Slacks blew up about it. This proves what I've always suspected, and was part of the case I made to the CSS WG: that this is a huge pain point. Hopefully the amount and intensity of positive reactions will help browsers prioritize this feature and add it to their roadmaps earlier rather than later. Across all these platforms, besides the "I can't wait for this to ship!" sentiment being most common, ther

## Introducing Light Mode

DevFeed: [Introducing Light Mode](<https://devfeed.tech/articles/introducing-light-mode-82719.md>)

Original publisher: [Read original article](<https://resend.com/blog/introducing-light-mode>)

Author: Zeh Fernandes

Published: 2024-01-20T00:00:00Z

Content type: article

Language: en

Sources: [Resend](<https://devfeed.tech/sources/resend.md>)

Topics: [Dark Mode](<https://devfeed.tech/topics/dark-mode.md>), [User interface design](<https://devfeed.tech/topics/ui-design.md>), [cdnjs](<https://devfeed.tech/topics/cdnjs.md>)

Tags: [accessibility](<https://devfeed.tech/tags/accessibility.md>), [code](<https://devfeed.tech/tags/code.md>), [configuration](<https://devfeed.tech/tags/configuration.md>), [css](<https://devfeed.tech/tags/css.md>), [css-variables](<https://devfeed.tech/tags/css-variables.md>), [dark-mode](<https://devfeed.tech/tags/dark-mode.md>), [figma](<https://devfeed.tech/tags/figma.md>), [lottie](<https://devfeed.tech/tags/lottie.md>), [product](<https://devfeed.tech/tags/product.md>)

### AI overview

Resend added a light theme to its dashboard after users reported difficulty with dark mode. The article describes designing for legibility and contrast, using Radix Colors and Tailwind CSS variables, adapting icons with CSS filters, and adding a theme option to its documentation.

### Source excerpt

Customize your Resend Dashboard experience with a light theme.

## CSS Style Queries

DevFeed: [CSS Style Queries](<https://devfeed.tech/articles/css-style-queries-45282.md>)

Original publisher: [Read original article](<https://ishadeed.com/article/css-container-style-queries/>)

Author: Ahmad Shadeed

Published: 2022-12-19T00:00:00Z

Content type: tutorial

Language: en

Sources: [Ahmad Shadeed](<https://devfeed.tech/sources/ahmad-shadeed.md>)

Topics: [CSS](<https://devfeed.tech/topics/css.md>), [browser](<https://devfeed.tech/topics/browser.md>), [Web platform](<https://devfeed.tech/topics/web-platform.md>), [Google Chrome](<https://devfeed.tech/topics/google-chrome.md>), [Web Development](<https://devfeed.tech/topics/web-development.md>), [border-image](<https://devfeed.tech/topics/border-image.md>)

Tags: [browsers](<https://devfeed.tech/tags/browsers.md>), [canary](<https://devfeed.tech/tags/canary.md>), [chrome](<https://devfeed.tech/tags/chrome.md>), [component](<https://devfeed.tech/tags/component.md>), [container](<https://devfeed.tech/tags/container.md>), [css](<https://devfeed.tech/tags/css.md>), [css-variables](<https://devfeed.tech/tags/css-variables.md>), [experimental](<https://devfeed.tech/tags/experimental.md>), [queries](<https://devfeed.tech/tags/queries.md>), [query](<https://devfeed.tech/tags/query.md>), [selector](<https://devfeed.tech/tags/selector.md>), [style](<https://devfeed.tech/tags/style.md>), [subgrid](<https://devfeed.tech/tags/subgrid.md>)

### AI overview

This tutorial explains CSS style queries, which query a container's CSS property or variable instead of its size. It describes their experimental implementation in Chrome Canary and contrasts them with container size queries.

### Source excerpt

For me, 2022 is the best year ever for CSS. We got a lot of new stuff supported in stable browsers and it's just like living a dream. From CSS subgrid, :has selector, container queries, and the new viewport units. So many things to grasp, I understand - but I'm sure we agree that this is exciting, isn't it? Recently, the Chrome team released experimental support for a new proposed CSS spec, style queries. In short, they let us query the style of a container, rather than the size only.

## Aligning Content In Different Wrappers

DevFeed: [Aligning Content In Different Wrappers](<https://devfeed.tech/articles/aligning-content-in-different-wrappers-45247.md>)

Original publisher: [Read original article](<https://ishadeed.com/article/aligning-content-different-wrappers/>)

Author: Ahmad Shadeed

Published: 2022-03-14T00:00:00Z

Content type: tutorial

Language: en

Sources: [Ahmad Shadeed](<https://devfeed.tech/sources/ahmad-shadeed.md>)

Topics: [CSS](<https://devfeed.tech/topics/css.md>), [layout](<https://devfeed.tech/topics/layout.md>), [Web Development](<https://devfeed.tech/topics/web-development.md>), [function](<https://devfeed.tech/topics/function.md>)

Tags: [align](<https://devfeed.tech/tags/align.md>), [calc](<https://devfeed.tech/tags/calc.md>), [content](<https://devfeed.tech/tags/content.md>), [css](<https://devfeed.tech/tags/css.md>), [css-variables](<https://devfeed.tech/tags/css-variables.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [layout](<https://devfeed.tech/tags/layout.md>), [max](<https://devfeed.tech/tags/max.md>), [padding](<https://devfeed.tech/tags/padding.md>), [viewport](<https://devfeed.tech/tags/viewport.md>), [wrapper](<https://devfeed.tech/tags/wrapper.md>)

### AI overview

A tutorial on aligning content across different wrappers in a responsive article layout. It derives dynamic padding from the viewport and wrapper widths, then applies CSS viewport units, calc(), max(), and CSS variables to keep the alignment consistent across screen sizes, including mobile.

### Source excerpt

How to align content with another section given that they are placed in different wrappers

## On Yak Shaving and \`\`, a new HTML element for Markdown

DevFeed: [On Yak Shaving and \`\`, a new HTML element for Markdown](<https://devfeed.tech/articles/on-yak-shaving-and-a-new-html-element-for-markdown-52135.md>)

Original publisher: [Read original article](<https://lea.verou.me/2021/11/on-yak-shaving-and-md-block-an-html-element-for-markdown/>)

Author: Lea Verou

Published: 2021-11-26T00:00:00Z

Content type: article

Language: en

Sources: [Lea Verou's blog](<https://devfeed.tech/sources/lea-verou-s-blog.md>)

Topics: [Web Development](<https://devfeed.tech/topics/web-development.md>), [Front end](<https://devfeed.tech/topics/frontend.md>), [Markdown](<https://devfeed.tech/topics/markdown.md>), [markup](<https://devfeed.tech/topics/markup.md>)

Tags: [blog](<https://devfeed.tech/tags/blog.md>), [component](<https://devfeed.tech/tags/component.md>), [conic-gradient](<https://devfeed.tech/tags/conic-gradient.md>), [css](<https://devfeed.tech/tags/css.md>), [css-variables](<https://devfeed.tech/tags/css-variables.md>), [demo](<https://devfeed.tech/tags/demo.md>), [docs](<https://devfeed.tech/tags/docs.md>), [esm](<https://devfeed.tech/tags/esm.md>), [gulp](<https://devfeed.tech/tags/gulp.md>), [js](<https://devfeed.tech/tags/js.md>), [library](<https://devfeed.tech/tags/library.md>), [markdown](<https://devfeed.tech/tags/markdown.md>), [markup](<https://devfeed.tech/tags/markup.md>), [module](<https://devfeed.tech/tags/module.md>), [nesting](<https://devfeed.tech/tags/nesting.md>), [npm](<https://devfeed.tech/tags/npm.md>), [open-source](<https://devfeed.tech/tags/open-source.md>), [original](<https://devfeed.tech/tags/original.md>), [personal](<https://devfeed.tech/tags/personal.md>), [postcss](<https://devfeed.tech/tags/postcss.md>), [readme](<https://devfeed.tech/tags/readme.md>), [releases](<https://devfeed.tech/tags/releases.md>), [rendering](<https://devfeed.tech/tags/rendering.md>), [sass](<https://devfeed.tech/tags/sass.md>), [stretchy](<https://devfeed.tech/tags/stretchy.md>), [web-components](<https://devfeed.tech/tags/web-components.md>), [yak-shaving](<https://devfeed.tech/tags/yak-shaving.md>)

### AI overview

To avoid duplicating Stretchy's documentation between its page and README, the author finished an existing web component for rendering inline and remote Markdown, published as md-block. The excerpt presents it as one step in a chain: updating Stretchy for ESM and Shadow DOM led to a Rollup and npm scripts build, CSS changes, and new documentation, before the author could return to the original demo project. The excerpt gives no implementation details or comparison with other Markdown tools.

### Source excerpt

This week has been Yak Shaving Galore. It went a bit like this: I've been working on a web component that I need for the project I'm working on. More on that later, but let's call it <x-foo> for now. Of course that needs to be developed as a separate reusable library and released as a separate open source project. No, this is not the titular component, this was only level 1 of my multi-level yak shaving... 🤦🏽♀ I wanted to showcase various usage examples of that component in its page, so I made another component for these demos: <x-foo-live>. This demo component would have markup with editable parts on one side and the live rendering on the other side. I wanted the editable parts to autosize as you type. Hey, I've written a library for that in the past, it's called Stretchy! But Stretchy was not written in ESM, nor did it support Shadow DOM. I must rewrite Stretchy in ESM and support Shadow DOM first! Surely it won't take more than a half hour, it's a tiny library. (It took more than a half hour) Ok, now I have a nice lil' module, but I also need to export IIFE as well, so that it's compatible with Stretchy v1. Let's switch to Rollup and npm scripts and ditch Gulp. Oh look, Stretchy's CSS is still written in Sass, even though it doesn't really need it now. Let's rewrite it to use CSS variables, use PostCSS for nesting, and use conic-gradient() instead of inline SVG data URIs. Ok, Stretchy v2 is ready, now I need to update its docs. Oooh, it doesn't have a README? I should add one. But I don't want to duplicate content between the page and the README. Hmmm, if only... I know! I'll make a web component for rendering both inline and remote Markdown! I have an unfinished one lying around somewhere, surely it won't take more than a couple hours to finish it? (It took almost a day, two with docs, demos etc) Done! Here it is! https://md-block.verou.me Great! Now I can update Stretchy's docs and release its v2 Great! Now I can use Stretchy in my <x-foo-live> component demoing

## Custom properties with defaults: 3+1 strategies

DevFeed: [Custom properties with defaults: 3+1 strategies](<https://devfeed.tech/articles/custom-properties-with-defaults-3-1-strategies-52134.md>)

Original publisher: [Read original article](<https://lea.verou.me/2021/10/custom-properties-with-defaults/>)

Author: Lea Verou

Published: 2021-10-15T00:00:00Z

Content type: article

Language: en

Sources: [Lea Verou's blog](<https://devfeed.tech/sources/lea-verou-s-blog.md>)

Topics: [UI components](<https://devfeed.tech/topics/ui-components.md>), [Front end](<https://devfeed.tech/topics/frontend.md>), [Web Components](<https://devfeed.tech/topics/web-components.md>), [Web Accessibility (a11y)](<https://devfeed.tech/topics/web-accessibility.md>)

Tags: [api](<https://devfeed.tech/tags/api.md>), [articles](<https://devfeed.tech/tags/articles.md>), [blog](<https://devfeed.tech/tags/blog.md>), [button](<https://devfeed.tech/tags/button.md>), [color](<https://devfeed.tech/tags/color.md>), [component](<https://devfeed.tech/tags/component.md>), [css](<https://devfeed.tech/tags/css.md>), [css-custom-properties](<https://devfeed.tech/tags/css-custom-properties.md>), [css-variables](<https://devfeed.tech/tags/css-variables.md>), [custom-properties](<https://devfeed.tech/tags/custom-properties.md>), [customizable](<https://devfeed.tech/tags/customizable.md>), [dynamic-css](<https://devfeed.tech/tags/dynamic-css.md>), [fallback](<https://devfeed.tech/tags/fallback.md>), [inheritance](<https://devfeed.tech/tags/inheritance.md>), [original](<https://devfeed.tech/tags/original.md>), [specificity](<https://devfeed.tech/tags/specificity.md>), [styling](<https://devfeed.tech/tags/styling.md>), [tutorials](<https://devfeed.tech/tags/tutorials.md>), [value](<https://devfeed.tech/tags/value.md>)

### AI overview

The excerpt compares ways to give a customizable component's `--color` property a default. Repeating `var(--color, black)` works but is verbose; assigning `--color: black` directly can block inherited values and force consumers to override the component's specificity. The author's preferred approach is a separate internal property such as `--_color: var(--color, black)`, then using `--_color` throughout the component. A fallback variable also works and lets consumers customize the default. As an alternative, `@property` can define an inheriting initial value and enable animation, but registration is global, may clash with host-page registrations, cannot provide per-declaration initial values, and cannot describe every custom property syntax. The excerpt notes `@property` support is limited to Chromium.

### Source excerpt

When developing customizable components, one often wants to expose various parameters of the styling as custom properties, and form a sort of CSS API. This is still underutlized, but there are libraries, e.g. Shoelace, that already list custom properties alongside other parts of each component's API (even CSS parts!). Note: I'm using "component" here broadly, as any reusable chunk of HTML/CSS/JS, not necessarily a web component or framework component. What we are going to discuss applies to reusable chunks of HTML just as much as it does to "proper" web components. Let's suppose we are designing a certain button styling, that looks like this: We want to support a --color custom property for creating color variations by setting multiple things internally: .fancy-button { border: .1em solid var(--color); background: transparent; color: var(--color); } .fancy-button:hover { background: var(--color); color: white; } Note that with the code above, if no --color is set, the three declarations using it will be IACVT and thus we'll get a nearly unstyled text-only button with no background on hover (transparent), no border on hover, and the default black text color (canvastext to be precise). That's no good! IT's important that we set defaults. However, using the fallback parameter for this gets tedious, and WET: .fancy-button { border: .1em solid var(--color, black); background: transparent; color: var(--color, black); } .fancy-button:hover { background: var(--color, black); color: white; } To avoid the repetition and still ensure --color always has a value, many people do this: .fancy-button { --color: black; border: .1em solid var(--color); background: transparent; color: var(--color); } .fancy-button:hover { background: var(--color); color: white; } However, this is not ideal for a number of reasons: It means that people cannot take advantage of inheritance to set --color on an ancestor. It means that people need to use specificity that overrides your own rules to set th

## 82% of developers get this 3 line CSS quiz wrong

DevFeed: [82% of developers get this 3 line CSS quiz wrong](<https://devfeed.tech/articles/82-of-developers-get-this-3-line-css-quiz-wrong-52131.md>)

Original publisher: [Read original article](<https://lea.verou.me/2021/05/82-of-developers-get-this-3-line-css-quiz-wrong/>)

Author: Lea Verou

Published: 2021-05-21T00:00:00Z

Content type: article

Language: en

Sources: [Lea Verou's blog](<https://devfeed.tech/sources/lea-verou-s-blog.md>)

Topics: [CSS](<https://devfeed.tech/topics/css.md>)

Tags: [blog](<https://devfeed.tech/tags/blog.md>), [css](<https://devfeed.tech/tags/css.md>), [css-variables](<https://devfeed.tech/tags/css-variables.md>), [custom-properties](<https://devfeed.tech/tags/custom-properties.md>), [demo](<https://devfeed.tech/tags/demo.md>), [dynamic-css](<https://devfeed.tech/tags/dynamic-css.md>), [inheritance](<https://devfeed.tech/tags/inheritance.md>), [poll](<https://devfeed.tech/tags/poll.md>), [properties](<https://devfeed.tech/tags/properties.md>), [property](<https://devfeed.tech/tags/property.md>), [transparent](<https://devfeed.tech/tags/transparent.md>), [twitter](<https://devfeed.tech/tags/twitter.md>), [workshop](<https://devfeed.tech/tags/workshop.md>)

### AI overview

In the quiz's CSS example, `--accent-color: revert` makes the `div` inherit `skyblue` from `:root`, so `var(--accent-color, orange)` does not use its fallback. The excerpt explains that `revert` removes the current style origin's changes; with no user or UA stylesheet value for this custom property, its inherited value applies. The excerpt also notes that a registered non-inheriting custom property requires an initial value, so it always resolves to a value and does not trigger the `var()` fallback. The non-inheriting behavior was demonstrated in Chrome only as of May 2021.

### Source excerpt

(I always wanted to do a clickbait title like this and when this chance came along I could not pass it up. 😅 Sorry!) While putting my ideas into slides for my Dynamic CSS workshop for next week, I was working on a slide explaining how the CSS wide keywords work with custom properties. inherit, initial, unset I had used numerous times and knew well. But what about revert? How did that work? I had an idea, but quickly coded up a demo to try it out. The code was: :root { --accent-color: skyblue; } div { --accent-color: revert; background: var(--accent-color, orange); } Phew, I was correct, but the amount of uncertainty I had before seeing the result tipped me that I might be on to something. Before you read on, take a moment to think about what you would vote. Warning: Spoilers ahead! 🤔 🤔 🤔 🤔 So I posted a quiz on Twitter: https://twitter.com/LeaVerou/status/1395379573190168576 These were the results after the 24 hours it ran for: orange was the clear winner, and the actual correct answer, skyblue only got 18.1%, nearly the same as transparent! If you got it wrong, you're in very good company: not only did 82% of poll respondents get it wrong as well, but even the editor of the CSS Variables spec and co-editor of CSS Cascading and Inheritance (which defines revert), Tab Atkins, told me privately that he got it wrong too: he voted for orange! (Yes, I did get his permission to mention this) So what actually happens? Why do we get skyblue? I will try to explain as best as I can. Let's start by what revert does: It reverts the cascaded value of the property from its current value to the value the property would have had if no changes had been made by the current style origin to the current element. This means it cancels out any author styles, and resets back to whatever value the property would have from the user stylesheet and UA stylesheet. Assuming there is no --accent-color declaration in the user stylesheet, and of course UA stylesheets don't set custom properties, th

## Practical Use Cases For CSS Variables

DevFeed: [Practical Use Cases For CSS Variables](<https://devfeed.tech/articles/practical-use-cases-for-css-variables-45366.md>)

Original publisher: [Read original article](<https://ishadeed.com/article/practical-css-variables/>)

Author: Ahmad Shadeed

Published: 2021-04-27T00:00:00Z

Content type: tutorial

Language: en

Sources: [Ahmad Shadeed](<https://devfeed.tech/sources/ahmad-shadeed.md>)

Topics: [CSS](<https://devfeed.tech/topics/css.md>), [Web Development](<https://devfeed.tech/topics/web-development.md>), [Variable](<https://devfeed.tech/topics/variable.md>), [User Interfaces](<https://devfeed.tech/topics/user-interfaces.md>)

Tags: [code](<https://devfeed.tech/tags/code.md>), [css](<https://devfeed.tech/tags/css.md>), [css-variables](<https://devfeed.tech/tags/css-variables.md>), [custom](<https://devfeed.tech/tags/custom.md>), [html](<https://devfeed.tech/tags/html.md>), [javascript](<https://devfeed.tech/tags/javascript.md>), [practical](<https://devfeed.tech/tags/practical.md>), [properties](<https://devfeed.tech/tags/properties.md>), [use-cases](<https://devfeed.tech/tags/use-cases.md>), [variables](<https://devfeed.tech/tags/variables.md>)

### AI overview

A practical tutorial on using CSS variables beyond simple color tokens. It covers reducing repeated CSS, varying longhand properties such as padding, simplifying CSS backgrounds, and dynamically supplying background image values with JavaScript.

### Source excerpt

The goal of this article is to walk you through use-cases where CSS variables shine.

## Dark mode in 5 minutes, with inverted lightness variables

DevFeed: [Dark mode in 5 minutes, with inverted lightness variables](<https://devfeed.tech/articles/dark-mode-in-5-minutes-with-inverted-lightness-variables-52130.md>)

Original publisher: [Read original article](<https://lea.verou.me/2021/03/inverted-lightness-variables/>)

Author: Lea Verou

Published: 2021-03-30T00:00:00Z

Content type: tutorial

Language: en

Sources: [Lea Verou's blog](<https://devfeed.tech/sources/lea-verou-s-blog.md>)

Topics: [Dark Mode](<https://devfeed.tech/topics/dark-mode.md>), [Media Queries](<https://devfeed.tech/topics/media-queries.md>), [color](<https://devfeed.tech/topics/color.md>), [User interface design](<https://devfeed.tech/topics/ui-design.md>)

Tags: [articles](<https://devfeed.tech/tags/articles.md>), [blog](<https://devfeed.tech/tags/blog.md>), [calc](<https://devfeed.tech/tags/calc.md>), [color](<https://devfeed.tech/tags/color.md>), [colors](<https://devfeed.tech/tags/colors.md>), [css](<https://devfeed.tech/tags/css.md>), [css-variables](<https://devfeed.tech/tags/css-variables.md>), [custom-properties](<https://devfeed.tech/tags/custom-properties.md>), [cycles](<https://devfeed.tech/tags/cycles.md>), [dark-mode](<https://devfeed.tech/tags/dark-mode.md>), [fallback](<https://devfeed.tech/tags/fallback.md>), [hsl](<https://devfeed.tech/tags/hsl.md>), [lch](<https://devfeed.tech/tags/lch.md>), [original](<https://devfeed.tech/tags/original.md>), [tutorials](<https://devfeed.tech/tags/tutorials.md>), [variables](<https://devfeed.tech/tags/variables.md>)

### AI overview

The excerpt presents a quick CSS dark mode by storing color lightness in custom properties and overriding them under `prefers-color-scheme: dark` with complementary values (100% minus the original lightness). This can adapt even inline colors without making every color a variable, but the author cautions that it is a rough starting point: HSL lightness is not perceptually uniform, so some colors and contrast may look poor and need manual adjustment. LCH lightness yields more uniform results in the examples, though the excerpt says browser support was limited and a fallback via `@supports` was needed. Sass loops can generate finer-grained lightness variables; a more DRY calculation using a direction variable is possible but makes color declarations harder to read.

### Source excerpt

By now, you probably know that you can use custom properties for individual color components, to avoid repeating the same color coordinates multiple times throughout your theme. You may even know that you can use the same variable for multiple components, e.g. HSL hue and lightness: :root { --primary-hs: 250 30%; } h1 { color: hsl(var(--primary-hs) 30%); } article { background: hsl(var(--primary-hs) 90%); } article h2 { background: hsl(var(--primary-hs) 40%); color: white; } Here is a very simple page designed with this technque: CodePen Embed Fallback Unlike preprocessor variables, you could even locally override the variable, to have blocks with a different accent color: :root { --primary-hs: 250 30%; --secondary-hs: 190 40%; } article { background: hsl(var(--primary-hs) 90%); } article.alt { --primary-hs: var(--secondary-hs); } CodePen Embed Fallback This is all fine and dandy, until dark mode comes into play. The idea of using custom properties to make it easier to adapt a theme to dark mode is not new. However, in every article I have seen, the strategy suggested is to create a bunch of custom properties, one for each color, and override them in a media query. This is a fine approach, and you'll likely want to do that for at least part of your colors eventually. However, even in the most disciplined of designs, not every color is a CSS variable. You often have colors declared inline, especially grays (e.g. the footer color in our example). This means that adding a dark mode is taxing enough that you may put it off for later, especially on side projects. The trick I'm going to show you will make anyone who knows enough about color cringe (sorry Chris!) but it does help you create a dark mode that works in minutes. It won't be great, and you should eventually tweak it to create a proper dark mode (also dark mode is not just about swapping colors) but it's better than nothing and can serve as a base. The basic idea is to use custom properties for the lightness of

## Styled-components best practices for React and CSS

DevFeed: [Styled-components best practices for React and CSS](<https://devfeed.tech/articles/the-styled-components-happy-path-45208.md>)

Original publisher: [Read original article](<https://www.joshwcomeau.com/css/styled-components/>)

Author: Josh W. Comeau

Published: 2021-01-25T11:30:00Z

Content type: tutorial

Language: en

Sources: [Josh Comeau's blog](<https://devfeed.tech/sources/josh-comeau-s-blog.md>)

Topics: [styled-components](<https://devfeed.tech/topics/styled-components.md>), [React](<https://devfeed.tech/topics/react.md>), [CSS](<https://devfeed.tech/topics/css.md>), [Library](<https://devfeed.tech/topics/library.md>), [Code](<https://devfeed.tech/topics/code.md>), [Web Development](<https://devfeed.tech/topics/web-development.md>)

Tags: [best-practices](<https://devfeed.tech/tags/best-practices.md>), [code](<https://devfeed.tech/tags/code.md>), [css](<https://devfeed.tech/tags/css.md>), [css-variables](<https://devfeed.tech/tags/css-variables.md>), [developers](<https://devfeed.tech/tags/developers.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [library](<https://devfeed.tech/tags/library.md>), [react](<https://devfeed.tech/tags/react.md>), [styled-components](<https://devfeed.tech/tags/styled-components.md>)

### AI overview

This article presents practical best practices for using styled-components to manage CSS in React applications. It focuses on CSS variables, performance, modularity, mental models, and reducing dependence on proprietary APIs.

### Source excerpt

styled-components is a wonderfully powerful styling library for React, and over the years I've learned a lot about how to use it effectively. This article shares my personal "best practices".

## A Quick Start Guide to CSS Custom Properties

DevFeed: [A Quick Start Guide to CSS Custom Properties](<https://devfeed.tech/articles/super-simple-start-to-css-variables-51879.md>)

Original publisher: [Read original article](<https://kentcdodds.com/blog/super-simple-start-to-css-variables>)

Published: 2020-10-28T00:00:00Z

Content type: tutorial

Language: en

Sources: [Kent C. Dodds Blog](<https://devfeed.tech/sources/kent-c-dodds-blog.md>)

Topics: [CSS](<https://devfeed.tech/topics/css.md>), [Web Development](<https://devfeed.tech/topics/web-development.md>), [selectors](<https://devfeed.tech/topics/selectors.md>), [Web platform](<https://devfeed.tech/topics/web-platform.md>)

Tags: [css](<https://devfeed.tech/tags/css.md>), [css-custom-properties](<https://devfeed.tech/tags/css-custom-properties.md>), [css-variables](<https://devfeed.tech/tags/css-variables.md>), [custom-properties](<https://devfeed.tech/tags/custom-properties.md>), [how-to](<https://devfeed.tech/tags/how-to.md>)

### AI overview

A concise introduction to CSS custom properties, also known as CSS variables. It explains how to define and scope them with selectors, how the cascade applies, and how JavaScript can change their values.

### Source excerpt

How to get started using css variables

## The --var: ; hack to toggle multiple values with one custom property

DevFeed: [The --var: ; hack to toggle multiple values with one custom property](<https://devfeed.tech/articles/the-var-hack-to-toggle-multiple-values-with-one-custom-property-52124.md>)

Original publisher: [Read original article](<https://lea.verou.me/2020/10/the-var-space-hack-to-toggle-multiple-values-with-one-custom-property/>)

Author: Lea Verou

Published: 2020-10-12T00:00:00Z

Content type: article

Language: en

Sources: [Lea Verou's blog](<https://devfeed.tech/sources/lea-verou-s-blog.md>)

Topics: [Web Development](<https://devfeed.tech/topics/web-development.md>), [User interface design](<https://devfeed.tech/topics/ui-design.md>), [if statement](<https://devfeed.tech/topics/if-statement.md>), [concatenation](<https://devfeed.tech/topics/concatenation.md>)

Tags: [all](<https://devfeed.tech/tags/all.md>), [allowed](<https://devfeed.tech/tags/allowed.md>), [apply](<https://devfeed.tech/tags/apply.md>), [background](<https://devfeed.tech/tags/background.md>), [blog](<https://devfeed.tech/tags/blog.md>), [border](<https://devfeed.tech/tags/border.md>), [box](<https://devfeed.tech/tags/box.md>), [but](<https://devfeed.tech/tags/but.md>), [button](<https://devfeed.tech/tags/button.md>), [call](<https://devfeed.tech/tags/call.md>), [can](<https://devfeed.tech/tags/can.md>), [code](<https://devfeed.tech/tags/code.md>), [color](<https://devfeed.tech/tags/color.md>), [css](<https://devfeed.tech/tags/css.md>), [css-variables](<https://devfeed.tech/tags/css-variables.md>), [custom](<https://devfeed.tech/tags/custom.md>), [hack](<https://devfeed.tech/tags/hack.md>), [multiple](<https://devfeed.tech/tags/multiple.md>), [original](<https://devfeed.tech/tags/original.md>), [property](<https://devfeed.tech/tags/property.md>), [tips](<https://devfeed.tech/tags/tips.md>), [toggle](<https://devfeed.tech/tags/toggle.md>), [values](<https://devfeed.tech/tags/values.md>), [var](<https://devfeed.tech/tags/var.md>), [with](<https://devfeed.tech/tags/with.md>)

### AI overview

The excerpt describes a CSS custom-property toggle: set a variable used in `var()` fallbacks to `initial` to activate the fallback values, or to whitespace (`--foo: ;`) to leave surrounding declarations unchanged. This can append or enable values across properties and rules using one variable, such as styling a raised button. The technique only supports appending values or choosing a whole value versus `initial`; it cannot express arbitrary alternatives such as red versus white backgrounds. The author notes readability concerns and suggests comments or named constants like `--ON` and `--OFF`. A proper CSS `if()` is described as a future alternative under discussion.

### Source excerpt

What if I told you you could use a single property value to turn multiple different values on and off across multiple different properties and even across multiple CSS rules? What if I told you you could turn this flat button into a glossy skeuomorphic button by just tweaking one custom property --is-raised, and that would set its border, background image, box and text shadows in one fell swoop? How, you may ask? The crux of this technique is this: There are two custom property values that work almost everywhere there is a var() call with a fallback. The more obvious one that you probably already know is the initial value, which makes the property just apply its fallback. So, in the following code: background: var(--foo, linear-gradient(white, transparent)) hsl(220 10% 50%); border: 1px solid var(--foo, rgb(0 0 0 / .1)); color: rgb(0 0 0 var(--foo, / .8)); We can set --foo to initial to enable these "fallbacks" and append these values to the property value, adding a gradient, setting a border-color, and making the text color translucent in one go. But what to do when we want to turn these values off? Any non-initial value for --foo (that doesn't create cycles) should work. But is there one that works in all three declarations? It turns out there is another value that works everywhere, in every property a var() reference is present, and you'd likely never guess what it is (unless you have watched any of my CSS variable talks and have a good memory for passing mentions of things). Intrigued? It's whitespace! Whitespace is significant in a custom property. When you write something like this: --foo: ; This is not an invalid declaration. This is a declaration where the value of --foo is literally one space character. However, whitespace is valid in every CSS property value, everywhere a var() is allowed, and does not affect its computed value in any way. So, we can just set our property to one space (or even a comment) and not affect any other value present in the declar

## CSS Variables 101

DevFeed: [CSS Variables 101](<https://devfeed.tech/articles/css-variables-101-45310.md>)

Original publisher: [Read original article](<https://ishadeed.com/article/css-vars-101/>)

Author: Ahmad Shadeed

Published: 2020-10-06T00:00:00Z

Content type: tutorial

Language: en

Sources: [Ahmad Shadeed](<https://devfeed.tech/sources/ahmad-shadeed.md>)

Topics: [CSS](<https://devfeed.tech/topics/css.md>), [Front end](<https://devfeed.tech/topics/frontend.md>), [Web Development](<https://devfeed.tech/topics/web-development.md>), [Programming](<https://devfeed.tech/topics/programming.md>)

Tags: [css](<https://devfeed.tech/tags/css.md>), [css-variables](<https://devfeed.tech/tags/css-variables.md>), [custom-properties](<https://devfeed.tech/tags/custom-properties.md>), [custom-variables](<https://devfeed.tech/tags/custom-variables.md>), [front-end](<https://devfeed.tech/tags/front-end.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [learn](<https://devfeed.tech/tags/learn.md>)

### AI overview

A detailed tutorial on CSS variables, also known as custom properties. It explains their purpose, reusable values, naming rules, scoping, overrides, and fallback values, with examples and use cases.

### Source excerpt

Learn about CSS variables (CSS custom properties) in detail.

[Next page](<https://devfeed.tech/tags/css-variables.md?cursor=WyIyMDIwLTEwLTA2VDAwOjAwOjAwKzAwOjAwIiwgImZiZTI1OWIzLTZmYjEtNDRlNC05MGViLTJkMzQzOTJmOGI0MCJd>)