Urgent.News

What's breaking now, across hundreds of outlets.

Tech

The beauty of CSS mixins

CSS mixins are a new construct in CSS that allow you to define a named piece of code that can be reused throughout a stylesheet. A mixin is similar to a custom property or CSS function, but it can return multiple values at once. Instead of defining a single value like background: red; color: white; border-radius: 2px;, a mixin can return all of those values together. Microsoft is working on implementing mixins in Chromium-based browsers, and they are very close to being ready for widespread use.

To define a mixin, you use the @mixin rule, and to apply it, you use the @apply rule. Mixin names start with two dashes, like custom properties. Once defined, a mixin can be reused anywhere in your stylesheet, just like a piece of CSS code written directly in the element's style block.

Mixins can also accept parameters, with optional types and default values. This allows you to create reusable components that can be customized for different elements. Additionally, mixins can hold conditional rules, such as @media, @supports, and @container, making them even more versatile. For example, you can create a mixin that applies styles conditionally based on the viewport size.

Another powerful feature of mixins is the ability to accept a block of CSS from the call site using the @contents rule. This allows you to pass additional declarations or custom styles when using the mixin, giving you more flexibility in your design. Mixins can also have private variables, which are not accessible to the element applying the mixin.

The potential use cases for mixins are extensive. For example, they can be used to define styles that only apply in dark mode, or to create responsive design breakpoints with named breakpoints. In a white-label website scenario, mixins can allow customers to customize the theme while keeping the original HTML and CSS untouched. This approach offers a balance between control and customization, giving you the best of both worlds.

Rewritten by urgent.news; may contain errors — check the original.

Source: patrickbrosset.com

Read the original at patrickbrosset.com →

Report a problem with this story

More in Tech

PrismML Ternary Bonsai 2.5 27B: A Local Setup Guide

The 5.9GB open model targets local coding agents, but choosing the right download matters as much as its compressed size.

  • PrismML releases 5.9GB Ternary Bonsai 2.5 27B model on November 24, 2026
  • Model designed for coding agents with llama.cpp fork requirement
  • Offers three GGUF packings (PTQ10, PQ20, Q20) and Apple MLX package

Why Client Emails Land in Spam After DNS Migrations (SPF 10-Lookup Limit, Duplicate DMARC & Cutover Diffing)

Every freelance web developer has lived through this exact horror story: you migrate a client's domain to Cloudflare, the new website loads in 120ms, SSL is green—and 3 hours later the client calls in…

  • Clients experience email deliverability issues after domain migrations to services like Cloudflare
  • Duplicate dmarc or v=spf1 records cause deliverability problems; merging with commas resolves issue

More from Thursday, 26 November 2026 →