#[non_exhaustive]pub struct Theme {Show 17 fields
pub primary: Color,
pub secondary: Color,
pub accent: Color,
pub text: Color,
pub text_dim: Color,
pub border: Color,
pub bg: Color,
pub success: Color,
pub warning: Color,
pub error: Color,
pub selected_bg: Color,
pub selected_fg: Color,
pub surface: Color,
pub surface_hover: Color,
pub surface_text: Color,
pub is_dark: bool,
pub spacing: Spacing,
}Expand description
A color theme that flows through all widgets automatically.
Construct with Theme::dark() or Theme::light(), or use
Theme::builder() for custom themes. Pass via crate::RunConfig
and every widget picks up the colors without any extra wiring.
§Example
use slt::{Color, Theme};
let theme = Theme::builder()
.primary(Color::Rgb(255, 107, 107))
.build();Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.primary: ColorPrimary accent color, used for focused borders and highlights.
secondary: ColorSecondary accent color, used for less prominent highlights.
accent: ColorAccent color for decorative elements.
text: ColorDefault foreground text color.
text_dim: ColorDimmed text color for secondary labels and hints.
border: ColorBorder color for unfocused containers.
bg: ColorBackground color. Typically Color::Reset to inherit the terminal background.
success: ColorColor for success states (e.g., toast notifications).
warning: ColorColor for warning states.
error: ColorColor for error states.
selected_bg: ColorBackground color for selected list/table rows.
selected_fg: ColorForeground color for selected list/table rows.
surface: ColorSubtle surface color for card backgrounds and elevated containers.
surface_hover: ColorHover/active surface color, one step brighter than surface.
Used for interactive element hover states. Should be visually
distinguishable from both surface and border.
surface_text: ColorSecondary text color guaranteed readable on surface backgrounds.
Use this instead of text_dim when rendering on surface-colored
containers. text_dim is tuned for the main bg; on surface it
may lack contrast.
is_dark: boolWhether this theme is a dark theme. Used to initialize dark mode in Context.
spacing: SpacingSpacing scale for consistent padding, margin, and gap values.
Implementations§
Source§impl Theme
impl Theme
Sourcepub fn resolve(&self, token: ThemeColor) -> Color
pub fn resolve(&self, token: ThemeColor) -> Color
Resolve a ThemeColor token to a concrete Color.
Sourcepub fn contrast_text_on(&self, bg: Color) -> Color
pub fn contrast_text_on(&self, bg: Color) -> Color
Return a text color with guaranteed contrast against the given background.
Delegates to Color::contrast_fg.
Sourcepub fn overlay(&self, color: Color, alpha: f32) -> Color
pub fn overlay(&self, color: Color, alpha: f32) -> Color
Blend a color with the theme’s background at the given alpha.
alpha = 0.0 returns self.bg, alpha = 1.0 returns color unchanged.
Sourcepub fn builder() -> ThemeBuilder
pub fn builder() -> ThemeBuilder
Create a ThemeBuilder for configuring a custom theme.
§Example
use slt::{Color, Theme};
let theme = Theme::builder()
.primary(Color::Rgb(255, 107, 107))
.accent(Color::Cyan)
.build();Sourcepub fn catppuccin() -> Self
pub fn catppuccin() -> Self
Catppuccin Mocha theme — lavender primary on dark base.
Sourcepub fn solarized_dark() -> Self
pub fn solarized_dark() -> Self
Solarized Dark theme — blue primary on dark base.
Sourcepub fn solarized_light() -> Self
pub fn solarized_light() -> Self
Solarized Light theme — warm ochre primary on light base.
Sourcepub fn tokyo_night() -> Self
pub fn tokyo_night() -> Self
Tokyo Night theme — blue primary on dark storm base.
Sourcepub fn gruvbox_dark() -> Self
pub fn gruvbox_dark() -> Self
Gruvbox Dark theme — warm, retro tones on dark background.