From de2980712f1e27b22c1a719f5ee5e09829c2755a Mon Sep 17 00:00:00 2001 From: Ren Amamiya Date: Mon, 16 Nov 2026 07:35:53 +0700 Subject: [PATCH] icons: default to ambient text color when unset --- crates/core/src/button.rs | 4 ++-- crates/icons/src/lib.rs | 11 +++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/crates/core/src/button.rs b/crates/core/src/button.rs index a488165..55160d6 100644 --- a/crates/core/src/button.rs +++ b/crates/core/src/button.rs @@ -288,12 +288,12 @@ impl RenderOnce for Button { .when_some(self.label, |content, label| content.child(label)) .children(self.children) .when_some(self.icon, |content, icon| { - content.child(icon.size(metrics.icon_size).color(foreground)) + content.child(icon.size(metrics.icon_size)) }) } else { content .when_some(self.icon, |content, icon| { - content.child(icon.size(metrics.icon_size).color(foreground)) + content.child(icon.size(metrics.icon_size)) }) .when_some(self.label, |content, label| content.child(label)) .children(self.children) diff --git a/crates/icons/src/lib.rs b/crates/icons/src/lib.rs index d2930ea..d189061 100644 --- a/crates/icons/src/lib.rs +++ b/crates/icons/src/lib.rs @@ -532,7 +532,7 @@ enum Glyph { Named(SharedString), } -/// An icon element. Unpainted unless a color is set. +/// An icon element. Painted with the ambient text color unless a color is set. #[derive(Clone, IntoElement)] pub struct Icon { glyph: Glyph, @@ -681,16 +681,19 @@ where } impl RenderOnce for Icon { - fn render(self, _window: &mut Window, _cx: &mut gpui::App) -> impl IntoElement { + fn render(self, window: &mut Window, _cx: &mut gpui::App) -> impl IntoElement { let Icon { glyph, size, color, transformation, } = self; + + let color = color.unwrap_or_else(|| window.text_style().color); + match glyph { - Glyph::Named(path) => Self::render_svg_path(size, color, transformation, path), - Glyph::Role(role) => Self::render_role(size, color, transformation, role), + Glyph::Named(path) => Self::render_svg_path(size, Some(color), transformation, path), + Glyph::Role(role) => Self::render_role(size, Some(color), transformation, role), } } }