Expand description
Style system for named styles, aliases, and YAML-based stylesheets.
This module provides the complete styling infrastructure:
§Core Types
StyleValue: A style that can be either concrete or an aliasStyles: A registry of named stylesStyleValidationError: Errors from style validation
§YAML Stylesheet Parsing
parse_stylesheet: Parse YAML into theme variantsThemeVariants: Styles resolved for base/light/dark modesStylesheetRegistry: File-based theme management
§YAML Schema
# Simple style with attributes
header:
fg: cyan
bold: true
# Shorthand for single attribute
bold_text: bold
accent: cyan
# Shorthand for multiple attributes
warning: "yellow italic"
# Adaptive style with mode-specific overrides
panel:
bg: gray
light:
bg: "#f5f5f5"
dark:
bg: "#1a1a1a"
# Aliases
disabled: muted§Color Formats
fg: red # Named (16 ANSI colors)
fg: bright_yellow # Bright variants
fg: 208 # 256-color palette
fg: "#ff6b35" # RGB hex
fg: [255, 107, 53] # RGB tuple§Example
use standout::style::{parse_stylesheet, ThemeVariants};
use standout::ColorMode;
let yaml = r#"
header:
fg: cyan
bold: true
footer:
dim: true
light:
fg: black
dark:
fg: white
"#;
let variants = parse_stylesheet(yaml).unwrap();
let dark_styles = variants.resolve(Some(ColorMode::Dark));Structs§
- Style
Attributes - Parsed style attributes from YAML.
- Styles
- A collection of named styles.
- Stylesheet
Registry - Registry for stylesheet/theme resolution from multiple sources.
- Theme
Variants - Theme variants containing styles for base, light, and dark modes.
Enums§
- Color
Def - Parsed color definition from stylesheet.
- Style
Definition - Parsed style definition from YAML.
- Style
Validation Error - Error returned when style validation fails.
- Style
Value - A style value that can be either a concrete style or an alias to another style.
- Stylesheet
Error - Error type for stylesheet parsing failures.
Constants§
- DEFAULT_
MISSING_ STYLE_ INDICATOR - Default prefix shown when a style name is not found.
- STYLESHEET_
EXTENSIONS - Recognized stylesheet file extensions in priority order.
Functions§
- parse_
css - Parses a CSS stylesheet and builds theme variants.
- parse_
stylesheet - Parses a YAML stylesheet and builds theme variants.