From 9900443ff18c5bab35f324c842c052f89203cca0 Mon Sep 17 00:00:00 2001 From: "Pedro M. de Echanove Pasquin" Date: Tue, 3 Nov 2026 17:05:43 +0100 Subject: [PATCH] Text in the theme's primary text colour unless given another, rather than white A `Text` given no colour was drawn white, which on a light theme's white surfaces could not be read: Prompt's dialog to share tabs showed neither the code nor the time left in it, and the titles of the clip_path, file_chooser and tab_strip examples, drawn over the theme's background, did not show in the light theme. `Text::new` now takes the theme's `text_primary`, as the toast, the text field and the pickers already do, so a label given no colour reads on light and dark themes alike. Its documentation and the test of its defaults say so. --- src/widget/text/mod.rs | 6 +++--- src/widget/text/tests.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/widget/text/mod.rs b/src/widget/text/mod.rs index 80c8f89..a04a793 100644 --- a/src/widget/text/mod.rs +++ b/src/widget/text/mod.rs @@ -66,15 +66,15 @@ pub struct Text impl Text { - /// A left-aligned, non-wrapping, ellipsis-truncated white label at the - /// default 16 px size with the canvas default font. + /// A left-aligned, non-wrapping, ellipsis-truncated label in the theme's + /// primary text colour at the default 16 px size with the canvas default font. pub fn new( content: impl Into ) -> Self { Self { content: content.into(), size: Length::px( 16.0 ), - color: Color::WHITE, + color: crate::theme::palette().text_primary, align: TextAlign::Left, wrap: false, truncate: true, diff --git a/src/widget/text/tests.rs b/src/widget/text/tests.rs index cf5b6aa..de58150 100644 --- a/src/widget/text/tests.rs +++ b/src/widget/text/tests.rs @@ -12,7 +12,7 @@ fn new_uses_documented_defaults() let t = Text::new( "hello" ); assert_eq!( t.content, "hello" ); assert_eq!( t.size, crate::Length::px( 16.0 ) ); - assert_eq!( t.color, Color::WHITE ); + assert_eq!( t.color, crate::theme::palette().text_primary ); assert_eq!( t.align, TextAlign::Left ); }