fix(theme): dark adw-gtk3 for dark palettes — GTK dialog buttons (#98)
Some checks failed
Check / eval (push) Has been cancelled

Stylix always used the light adw-gtk3 sheet with recolored tokens; that
sheet hardcodes near-black button labels, which became black-on-dark in
Boreal GTK dialogs. Force adw-gtk3-dark (and prefer-dark) for dark mode,
and pin dialog button label colours in Stylix extraCss.
This commit is contained in:
2026-07-15 12:06:38 +01:00
parent edc1415521
commit e9dd3d14c5
5 changed files with 75 additions and 20 deletions

View File

@@ -54,6 +54,13 @@ in
# contrast selected rows + explicit arrow colour. Appended to
# Stylix's generated gtk.css (not gtk.gtk3.extraCss — that is a
# no-op under Stylix).
#
# #98: dialog button labels. Stylix always installs theme name
# "adw-gtk3" (light sheet) and only recolors @define-color vars.
# The light sheet hardcodes dark/black button text in places; on a
# dark palette that becomes black-on-dark in GTK dialogs. We force
# adw-gtk3-dark for dark mode (below) and still pin button label
# colours here so dialogs stay legible if a light sheet slips in.
extraCss = ''
menu menuitem, .menu menuitem, .context-menu menuitem {
color: #${base16.base05};
@@ -95,6 +102,33 @@ in
background-color: #${base16.base0D};
color: #${base16.base00};
}
/* Dialog / message-box action buttons (#98). */
button, button label,
.dialog-action-area button,
.dialog-action-area button label,
messagedialog button,
messagedialog button label,
.message-dialog button,
.message-dialog button label {
color: #${base16.base05};
}
button:disabled, button:disabled label {
color: alpha(#${base16.base05}, 0.5);
}
/* Suggested/destructive sit on pastel accent/bad dark label
is intentional and contrast-checked (~4:1 on Boreal accent). */
button.suggested-action, button.suggested-action label,
button.destructive-action, button.destructive-action label,
button.default, button.default label {
color: #${base16.base00};
}
button.suggested-action.flat, button.suggested-action.flat label {
color: #${base16.base0D};
}
button.destructive-action.flat, button.destructive-action.flat label {
color: #${base16.base08};
}
'';
};
qt.enable = true;
@@ -147,7 +181,23 @@ in
# udiskie — are built as image menu items, so without this their icons
# silently vanish. Stylix drives the HM gtk module, so extraConfig
# merges into the same settings.ini it already writes.
gtk.gtk3.extraConfig."gtk-menu-images" = 1;
gtk.gtk3.extraConfig = {
"gtk-menu-images" = 1;
# Pair with adw-gtk3-dark so the theme sheet itself is dark, not just
# the @define-color recolor (see gtk.theme.name below).
"gtk-application-prefer-dark-theme" = t.mode != "light";
};
gtk.gtk4.extraConfig."gtk-application-prefer-dark-theme" = t.mode != "light";
# #98: Stylix hardcodes gtk.theme.name = "adw-gtk3" (light CSS) for every
# polarity and only injects libadwaita colour tokens. The light adw-gtk3
# sheet assumes light chrome and hardcodes near-black button labels in
# places — on Boreal that is black text on dark dialog buttons. Force
# the matching dark/light sheet; the package still provides both names.
gtk.theme = {
package = lib.mkDefault pkgs.adw-gtk3;
name = lib.mkForce (if t.mode == "light" then "adw-gtk3" else "adw-gtk3-dark");
};
# GTK4/libadwaita and Qt6 apps decide dark vs light from the XDG
# portal's color-scheme (org.freedesktop.appearance), which
@@ -155,7 +205,12 @@ in
# the GTK theme and `polarity` but not this, so a light theme still
# rendered libadwaita/Qt apps dark (and vice-versa). Drive it from the
# palette mode. (programs.dconf.enable is already on system-side.)
dconf.settings."org/gnome/desktop/interface".color-scheme =
if t.mode == "light" then "prefer-light" else "prefer-dark";
dconf.settings."org/gnome/desktop/interface" = {
color-scheme =
if t.mode == "light" then "prefer-light" else "prefer-dark";
gtk-theme =
if t.mode == "light" then "adw-gtk3" else "adw-gtk3-dark";
};
};
}