<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/the-beauty-of-css-mixins-2jcsyqan9" -->

---
title: The beauty of CSS mixins | daily.dev
description: CSS mixins let you define a named block of declarations, including nested rules, once and reuse it with `@apply`. You define one with `@mixin --name`, and it...
canonical: https://daily.dev/posts/the-beauty-of-css-mixins-2jcsyqan9
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: The beauty of CSS mixins | daily.dev
og:description: CSS mixins let you define a named block of declarations, including nested rules, once and reuse it with `@apply`. You define one with `@mixin --name`, and it...
og:url: https://daily.dev/posts/the-beauty-of-css-mixins-2jcsyqan9
og:image: https://api.daily.dev/og/posts/2JCsYqan9.png
og:image:alt: The beauty of CSS mixins
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# The beauty of CSS mixins

**[Patrick Brosset](https://daily.dev/sources/patrickbrosset)** · 11 min read · 0 upvotes · 1 comments

## Summary

CSS mixins let you define a named block of declarations, including nested rules, once and reuse it with `@apply`. You define one with `@mixin --name`, and it can take typed parameters with default values. `@contents` lets the caller pass in its own block of CSS, which enables named breakpoints like `--mobile` and `--desktop` and conditional mixins like `--if-dark-mode`. `@private` blocks keep variables hidden from the element that applies the mixin. Patrick Brosset's Zen Garden-style demo uses undefined mixins as theming extension points. Mixins are experimental, work only in Chromium behind a flag, and nested selectors can expose your markup again.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://patrickbrosset.com/articles/2026-11-25-the-beauty-of-css-mixins>

## Questions this post answers

### How do I define and use a CSS mixin with parameters and default values?

Define a mixin with the @mixin rule, using a name that starts with two dashes, and apply it with @apply. Parameters can have types and defaults, for example @mixin --button(--bg <color>: royalblue, --fg <color>: white). Call it as @apply --button; for defaults or @apply --button(crimson); to override. Passing more arguments than parameters makes @apply do nothing.

_Developers tracking new CSS features keep up with mixins and similar proposals on daily.dev._

### How can I create named breakpoints in CSS without a preprocessor?

Use mixins that wrap an @media query around @contents. For example, @mixin --mobile { @media (width < 40rem) { @contents; } } defines a named breakpoint, and you apply it with @apply --mobile { display: none; }. Define --tablet and --desktop the same way, and the breakpoints are maintained in one place and reused across the site.

_Anyone planning a responsive design system can follow new CSS capabilities like this on daily.dev._

### Can I use CSS mixins in browsers today?

CSS mixins are experimental and work only in Chromium-based browsers behind a flag. To try them, open about://flags in a recent Chromium browser and enable the Experimental Web Platform features flag. Microsoft's Chromium team is implementing them and getting ready to ship, but other browsers have not yet caught up.

_Developers deciding when to adopt new CSS can watch browser support news on daily.dev._

## Community discussion

Top comments from developers on daily.dev.

**@codagonist** · 0 upvotes

> Going back in time with this one :)

## Similar posts on daily.dev

- [Mixin Zen Garden: The Beauty of CSS Mixins](https://daily.dev/posts/mixin-zen-garden-the-beauty-of-css-mixins-zyawlmgea) · Patrick Brosset · 0 upvotes · 0 comments
- [Thoughts on Native CSS Mixins – Frontend Masters Blog](https://daily.dev/posts/thoughts-on-native-css-mixins-frontend-masters-blog-wvt8d5ikq) · Frontend Masters · 11 upvotes · 0 comments
- [CSS-Tricks](https://daily.dev/posts/css-tricks-vkofgouts) · CSS-Tricks · 11 upvotes · 1 comments
- [Native CSS Nesting](https://daily.dev/posts/native-css-nesting-r3p5s5hro) · Flavio Copes · 15 upvotes · 2 comments
- [CSS @scope: An Alternative To Naming Conventions And Heavy Abstractions — Smashing Magazine](https://daily.dev/posts/css-scope-an-alternative-to-naming-conventions-and-heavy-abstractions-smashing-magazine-bznxvwrpv) · Smashing Magazine · 2 upvotes · 0 comments

---

Tags: [#css](https://daily.dev/tags/css), [#ui-design](https://daily.dev/tags/ui-design), [#chromium](https://daily.dev/tags/chromium)

[View this post on daily.dev](https://daily.dev/posts/the-beauty-of-css-mixins-2jcsyqan9)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"The beauty of CSS mixins","url":"https://daily.dev/posts/the-beauty-of-css-mixins-2jcsyqan9","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/the-beauty-of-css-mixins-2jcsyqan9"},"datePublished":"2026-11-25T17:59:39.638Z","dateModified":"2026-11-25T18:00:02.463Z","description":"CSS mixins let you define a named block of declarations, including nested rules, once and reuse it with `@apply`. You define one with `@mixin --name`, and it...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/12030f65877a1647e0b9d7c1d8fcebb1?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/12030f65877a1647e0b9d7c1d8fcebb1?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Patrick Brosset","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Patrick Brosset","logo":"https://media.daily.dev/image/upload/s--AD7IzOuB--/f_auto,q_auto/v1774179622/logos/patrickbrosset","url":"https://daily.dev/sources/patrickbrosset"},"commentCount":1,"discussionUrl":"https://daily.dev/posts/the-beauty-of-css-mixins-2jcsyqan9","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":1}],"keywords":"css,ui-design,chromium","timeRequired":"PT11M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Patrick Brosset","item":"https://daily.dev/sources/patrickbrosset"},{"@type":"ListItem","position":3,"name":"The beauty of CSS mixins"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/the-beauty-of-css-mixins-2jcsyqan9","comment":[{"@type":"Comment","text":"Going back in time with this one :)","datePublished":"2026-11-26T09:34:14.111Z","url":"https://daily.dev/posts/2JCsYqan9#c-Q8njMxGf4","author":{"@type":"Person","name":"codagonist","url":"https://daily.dev/codagonist","image":"https://media.daily.dev/image/upload/s--ynHsGojZ--/f_auto/v1767932812/avatars/avatar_xDH2kQR3_7?_a=BAMAMiZW0"}}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/the-beauty-of-css-mixins-2jcsyqan9#faq","mainEntity":[{"@type":"Question","name":"How do I define and use a CSS mixin with parameters and default values?","acceptedAnswer":{"@type":"Answer","text":"Define a mixin with the @mixin rule, using a name that starts with two dashes, and apply it with @apply. Parameters can have types and defaults, for example @mixin --button(--bg \u003ccolor\u003e: royalblue, --fg \u003ccolor\u003e: white). Call it as @apply --button; for defaults or @apply --button(crimson); to override. Passing more arguments than parameters makes @apply do nothing. Developers tracking new CSS features keep up with mixins and similar proposals on daily.dev."}},{"@type":"Question","name":"How can I create named breakpoints in CSS without a preprocessor?","acceptedAnswer":{"@type":"Answer","text":"Use mixins that wrap an @media query around @contents. For example, @mixin --mobile { @media (width \u003c 40rem) { @contents; } } defines a named breakpoint, and you apply it with @apply --mobile { display: none; }. Define --tablet and --desktop the same way, and the breakpoints are maintained in one place and reused across the site. Anyone planning a responsive design system can follow new CSS capabilities like this on daily.dev."}},{"@type":"Question","name":"Can I use CSS mixins in browsers today?","acceptedAnswer":{"@type":"Answer","text":"CSS mixins are experimental and work only in Chromium-based browsers behind a flag. To try them, open about://flags in a recent Chromium browser and enable the Experimental Web Platform features flag. Microsoft's Chromium team is implementing them and getting ready to ship, but other browsers have not yet caught up. Developers deciding when to adopt new CSS can watch browser support news on daily.dev."}}]}
```

