Skip to content

Commit 3c55e07

Browse files
authored
Merge pull request #2500 from iced-rs/builtin-text-styles
Add some built-in text styles for each `Palette` color
2 parents aaab986 + 03e8078 commit 3c55e07

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

core/src/widget/text.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,34 @@ impl Catalog for Theme {
367367
}
368368
}
369369

370+
/// Text conveying some important information, like an action.
371+
pub fn primary(theme: &Theme) -> Style {
372+
Style {
373+
color: Some(theme.palette().primary),
374+
}
375+
}
376+
377+
/// Text conveying some secondary information, like a footnote.
378+
pub fn secondary(theme: &Theme) -> Style {
379+
Style {
380+
color: Some(theme.extended_palette().secondary.strong.color),
381+
}
382+
}
383+
384+
/// Text conveying some positive information, like a successful event.
385+
pub fn success(theme: &Theme) -> Style {
386+
Style {
387+
color: Some(theme.palette().success),
388+
}
389+
}
390+
391+
/// Text conveying some negative information, like an error.
392+
pub fn danger(theme: &Theme) -> Style {
393+
Style {
394+
color: Some(theme.palette().danger),
395+
}
396+
}
397+
370398
/// A fragment of [`Text`].
371399
///
372400
/// This is just an alias to a string that may be either

0 commit comments

Comments
 (0)