Skip to content

Conversation

5I-I5
Copy link
Contributor

@5I-I5 5I-I5 commented Apr 13, 2025

✨ Add automatic dark/light theme support via prefers-color-scheme

This update adds system theme synchronization to zebar using the CSS media query prefers-color-scheme.
Now, zebar will automatically adapt to your operating system's light or dark mode — no manual toggling required.

🎨 What changed

  • Replaced hardcoded colors with CSS variables.
  • Introduced media queries for prefers-color-scheme: light and prefers-color-scheme: dark.
  • Added new CSS variables for:
    • --text-size
    • --icon-size
    • Making it easier to adjust font and icon sizes independently.
  • The interface now updates automatically with system theme changes.

🧠 Motivation

As a Windows 11 user with auto dark mode based on sunset/sunrise, I’ve always found it frustrating that the default zebar preset didn’t follow the system theme.
This small but meaningful tweak makes zebar feel more native, more modern, and better integrated into the daily workflow.

Also, there was previously no convenient way to customize font or icons size. With the new variables, it's now a little bit easier to adjust the UI to our preferences.

✅ Compatibility

  • Tested on Windows 11 with automatic theme switching.
  • Since it uses a standard CSS media query, it should work seamlessly on macOS and most Linux desktop environments as well.

🔄 Related

This might be an alternative way to partly resolve #203.

📸 Demo

Before (always dark mode)

before.mp4

After (auto light/dark)

after.mp4

Thanks for creating and maintaining glazewm & zebar 🙌

This update introduces automatic theme synchronization with the system's dark/light mode using the CSS media query `prefers-color-scheme`. 

It replaces hardcoded colors with CSS variables and adds root-level light/dark definitions, ensuring the UI adapts dynamically based on user system settings.

As a user on Windows 11 with an auto-scheduler for dark mode (based on sunset/sunrise), I often found it frustrating that the default zebar preset didn’t follow the system theme. This small but meaningful change makes zebar feel much more native and integrated into the daily flow.

Tested on Windows, but the change is CSS-standard-based, so it should work on macOS and Linux as well.
@5I-I5
Copy link
Contributor Author

5I-I5 commented Apr 13, 2025

📝Note: This is a replacement for #211 (which used an automatically generated branch name patch-1). Reopened here with a proper branch name: feat/auto-dark-light-theme.

@lars-berger lars-berger changed the title Add auto dark/light theme support via styles.css feat: add auto dark/light theme support via styles.css May 21, 2025
@lars-berger
Copy link
Member

This is super cool, thanks for putting this together! The CSS vars should make it easier for people to theme their colors as well 🙌

Apologies for getting around to reviewing this so late. I've been working on and off on a major v3 version bump which has a bunch of changes, but it's finally good to go. I'll get this PR included in a beta release of v3 later today. Btw for a lot of OSS projects, the branch names for PR's usually don't matter since we squash the commits anyways.

@lars-berger lars-berger changed the title feat: add auto dark/light theme support via styles.css feat: add auto dark/light theme support to starter config via prefers-color-scheme May 21, 2025
@lars-berger lars-berger merged commit 3d7bfe0 into glzr-io:main May 21, 2025
@github-project-automation github-project-automation bot moved this from 📬 Needs triage to ✅ Done in zebar May 21, 2025
Copy link

🎉 This PR is included in version 3.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

[Feature Request] [Probider] Windows theme (light-dark mode, acrilyc mode).
2 participants