<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/automatic-dark-mode-in-avalonia-from-a-single-theme-j0imgwoyd" -->

---
title: Automatic Dark Mode in Avalonia From a Single Theme
description: I built automatic dark mode directly into my Avalonia theme engine — one theme definition that handles light and dark for you.  No duplicate styles, no manual...
canonical: https://daily.dev/posts/automatic-dark-mode-in-avalonia-from-a-single-theme-j0imgwoyd
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Automatic Dark Mode in Avalonia From a Single Theme | daily.dev
og:description: I built automatic dark mode directly into my Avalonia theme engine — one theme definition that handles light and dark for you.  No duplicate styles, no manual...
og:url: https://daily.dev/posts/automatic-dark-mode-in-avalonia-from-a-single-theme-j0imgwoyd
og:image: https://api.daily.dev/og/posts/j0IMGwoyD.png
og:image:alt: Automatic Dark Mode in Avalonia From a Single Theme
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.

# Automatic Dark Mode in Avalonia From a Single Theme

**[AngelSix](https://daily.dev/sources/angelsix)** · 10 min read · 0 upvotes · 0 comments

## Summary

I built automatic dark mode directly into my Avalonia theme engine — one theme definition that handles light and dark for you.

No duplicate styles, no manual dark one / light seven on every control. Define your colors once, and source generators + color maps automatically convert contrasts, states, and ramps between modes. And when you don't like what it picks, you can override it per-brush.

This is part of a complete series on building a fully custom Avalonia UI theme from scratch, hand-coded with zero AI assistance.

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📌 WHAT YOU'LL LEARN
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
• How automatic dark mode works from a single theme definition
• How source generators bake light-to-dark conversion into the engine
• How to override auto colors per-brush - red in light, blue in dark
• Why fixed colors like dark one / light seven were replaced with tokens
• The new token system for theme defaults - surface, text, hover, background
• How changing one token value retints every button and label instantly
• How to scope dark mode to just one region of your UI

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⏱ TIMESTAMPS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
[0:00] – Automatic dark mode from a single theme
[0:35] – Fully customizable - you're not locked in
[0:44] – How it's baked into the theme engine with source generators
[1:16] – Demo - red accent in light becomes blue in dark
[2:16] – Coming next - opt-out flag for static colors
[3:07] – Open source update + what changed
[3:20] – Goodbye dark one / light seven - moving to tokens
[3:54] – New token system - surface, text, hover, background defaults
[5:30] – Demo - retint every button and label from one value
[6:32] – Fixing label inheritance in partial dark regions
[7:40] – Partial dark mode - theming just one region
[9:14] – Wrap + next up - remaking the date/calendar control

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔗 LINKS & RESOURCES
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
▶ Full Avalonia Themes Playlist: https://www.youtube.com/playlist?list=PLrW43fNmjaQVE2vDBeWD8QYIm06w6bKyO
▶ Source Code (AvaloniaThemeLab): https://github.com/angelsix/youtube/tree/develop/AvaloniaThemeLab
▶ GitHub: https://github.com/angelsix
▶ Website: https://www.angelsix.com

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📚 SERIES — Avalonia UI Theming – Hand Coded From Scratch
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
01 — Setup — https://www.youtube.com/watch?v=rUKlQnjU0tc
02 — Buttons | Hand Coded From Scratch — https://www.youtube.com/watch?v=oKjk6pyyARI
03 — Button Spinner | Anatomy & Internals — https://www.youtube.com/watch?v=WMaTbXkvm9g
04 — Designing a Theme System From Scratch — https://www.youtube.com/watch?v=I5halHoNfH0
05 — Checkbox Control Deep Dive — https://www.youtube.com/watch?v=uIimnwjITT0
06 — Checkbox Styling — https://www.youtube.com/watch?v=uv1bNrfCjtY
07 — Theme Engine From Scratch — https://www.youtube.com/watch?v=NXz8hwITg5U
08 — Building a Design Token System — https://www.youtube.com/watch?v=QMVdxRZqaU8
09 — One Token System for the Entire Theme — https://www.youtube.com/watch?v=JEcD1XXIiA8
10 — Avalonia Styles Not Working? You're Breaking This Rule — https://www.youtube.com/watch?v=OhJN8Ssp2hA
11 — Avalonia Just Got a Full Icon System — https://www.youtube.com/watch?v=N5HPe5GYCPo
12 — Breaking Every Avalonia Control On Purpose — https://www.youtube.com/watch?v=OmVFU-iowqI
13 — Avalonia Tool That Finds Bugs My Compiler Can't See — https://www.youtube.com/watch?v=WQB5kFJWRmc
14 — The Avalonia Accent System That Generates Its Own Shades — https://www.youtube.com/watch?v=YFQEVLaYk94
15 — The Color Ramp That Themes Your Whole App — https://www.youtube.com/watch?v=xhnUQOOrShs
16 — Theme Token Reduction (One File, Every Control) — https://www.youtube.com/watch?v=tg2gSQRJtmY
17 — This Video — Automatic Dark Mode From a Single Theme

#avalonia #avaloniaui #xaml #csharp #dotnet #uiux #desktopapp #softwaretutorial #coding

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.youtube.com/watch?v=m2WjfZAOUyM>

---

Tags: [#avalonia](https://daily.dev/tags/avalonia)

[View this post on daily.dev](https://daily.dev/posts/automatic-dark-mode-in-avalonia-from-a-single-theme-j0imgwoyd)

```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":"Automatic Dark Mode in Avalonia From a Single Theme","url":"https://daily.dev/posts/automatic-dark-mode-in-avalonia-from-a-single-theme-j0imgwoyd","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/automatic-dark-mode-in-avalonia-from-a-single-theme-j0imgwoyd"},"datePublished":"2026-10-04T13:04:32.113Z","dateModified":"2026-10-04T21:57:11.216Z","description":"I built automatic dark mode directly into my Avalonia theme engine — one theme definition that handles light and dark for you.\n\nNo duplicate styles, no manual...","image":"https://i.ytimg.com/vi/m2WjfZAOUyM/sddefault.jpg","thumbnailUrl":"https://i.ytimg.com/vi/m2WjfZAOUyM/sddefault.jpg","isAccessibleForFree":true,"articleSection":"AngelSix","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":"AngelSix","logo":"https://media.daily.dev/image/upload/s--h1ikmN_u--/f_auto,q_auto/v1791119063/logos/angelsix?_a=BAMAMicg0","url":"https://daily.dev/sources/angelsix"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/automatic-dark-mode-in-avalonia-from-a-single-theme-j0imgwoyd","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"avalonia","timeRequired":"PT10M","video":{"@type":"VideoObject","name":"Automatic Dark Mode in Avalonia From a Single Theme","description":"I built automatic dark mode directly into my Avalonia theme engine — one theme definition that handles light and dark for you.\n\nNo duplicate styles, no manual...","thumbnailUrl":"https://i.ytimg.com/vi/m2WjfZAOUyM/sddefault.jpg","uploadDate":"2026-10-04T13:04:32.113Z","duration":"PT10M","url":"https://api.daily.dev/r/j0IMGwoyD","embedUrl":"https://www.youtube.com/embed/m2WjfZAOUyM"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"AngelSix","item":"https://daily.dev/sources/angelsix"},{"@type":"ListItem","position":3,"name":"Automatic Dark Mode in Avalonia From a Single Theme"}]}
```

