pub struct Theme {Show 19 fields
pub primary: AdaptiveColor,
pub secondary: AdaptiveColor,
pub accent: AdaptiveColor,
pub background: AdaptiveColor,
pub surface: AdaptiveColor,
pub overlay: AdaptiveColor,
pub text: AdaptiveColor,
pub text_muted: AdaptiveColor,
pub text_subtle: AdaptiveColor,
pub success: AdaptiveColor,
pub warning: AdaptiveColor,
pub error: AdaptiveColor,
pub info: AdaptiveColor,
pub border: AdaptiveColor,
pub border_focused: AdaptiveColor,
pub selection_bg: AdaptiveColor,
pub selection_fg: AdaptiveColor,
pub scrollbar_track: AdaptiveColor,
pub scrollbar_thumb: AdaptiveColor,
}Expand description
A theme with semantic color slots.
Themes provide consistent styling across an application by mapping semantic names (like “error” or “primary”) to actual colors.
Fields§
§primary: AdaptiveColorPrimary accent color (e.g., buttons, highlights).
secondary: AdaptiveColorSecondary accent color.
accent: AdaptiveColorTertiary accent color.
background: AdaptiveColorMain background color.
surface: AdaptiveColorSurface color (cards, panels).
overlay: AdaptiveColorOverlay color (dialogs, dropdowns).
text: AdaptiveColorPrimary text color.
text_muted: AdaptiveColorMuted text color.
text_subtle: AdaptiveColorSubtle text color (hints, placeholders).
success: AdaptiveColorSuccess color (green).
warning: AdaptiveColorWarning color (yellow/orange).
error: AdaptiveColorError color (red).
info: AdaptiveColorInfo color (blue).
border: AdaptiveColorDefault border color.
border_focused: AdaptiveColorFocused element border.
selection_bg: AdaptiveColorSelection background.
selection_fg: AdaptiveColorSelection foreground.
scrollbar_track: AdaptiveColorScrollbar track color.
scrollbar_thumb: AdaptiveColorScrollbar thumb color.
Implementations§
Source§impl Theme
impl Theme
Sourcepub fn builder() -> ThemeBuilder
pub fn builder() -> ThemeBuilder
Create a new theme builder.
Sourcepub fn detect_dark_mode() -> bool
pub fn detect_dark_mode() -> bool
Detect whether dark mode should be used.
Detection heuristics:
- Check COLORFGBG environment variable
- Default to dark mode (most terminals are dark)
Note: OSC 11 background query would be more accurate but requires terminal interaction which isn’t always safe or fast.
Sourcepub fn resolve(&self, is_dark: bool) -> ResolvedTheme
pub fn resolve(&self, is_dark: bool) -> ResolvedTheme
Create a resolved copy of this theme for a specific mode.
This flattens all adaptive colors to fixed colors based on the mode.