Skip to content

Commit

Permalink
Merge pull request #2500 from iced-rs/builtin-text-styles
Browse files Browse the repository at this point in the history
Add some built-in text styles for each `Palette` color
  • Loading branch information
hecrj authored Jul 11, 2024
2 parents aaab986 + 03e8078 commit 3c55e07
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions core/src/widget/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,34 @@ impl Catalog for Theme {
}
}

/// Text conveying some important information, like an action.
pub fn primary(theme: &Theme) -> Style {
Style {
color: Some(theme.palette().primary),
}
}

/// Text conveying some secondary information, like a footnote.
pub fn secondary(theme: &Theme) -> Style {
Style {
color: Some(theme.extended_palette().secondary.strong.color),
}
}

/// Text conveying some positive information, like a successful event.
pub fn success(theme: &Theme) -> Style {
Style {
color: Some(theme.palette().success),
}
}

/// Text conveying some negative information, like an error.
pub fn danger(theme: &Theme) -> Style {
Style {
color: Some(theme.palette().danger),
}
}

/// A fragment of [`Text`].
///
/// This is just an alias to a string that may be either
Expand Down

0 comments on commit 3c55e07

Please sign in to comment.