Skip to main content

Module themes

Module themes 

Source
Expand description

Theme system for fastapi_rust console output.

Defines color palettes, icons, spacing, and box styles for consistent visual output across all components. Colors follow the FastAPI visual identity and Swagger UI conventions for familiarity.

§Theme Presets

  • FastApi - Default theme inspired by FastAPI documentation
  • Neon - High-contrast cyberpunk theme
  • Minimal - Grayscale with subtle accents
  • Monokai - Dark theme inspired by the Monokai color scheme
  • Light - Optimized for light terminal backgrounds
  • Accessible - High-contrast, WCAG-compliant colors

§Components

§Example

use fastapi_output::themes::{FastApiTheme, ThemePreset, ThemeIcons, ThemeSpacing};

// Get default theme
let theme = FastApiTheme::default();

// Get theme by preset
let neon = FastApiTheme::from_preset(ThemePreset::Neon);

// Use icons (with ASCII fallback)
let icons = ThemeIcons::unicode();
println!("{} Success!", icons.success);

// Consistent spacing
let spacing = ThemeSpacing::default();
let indent = " ".repeat(spacing.indent);

// Parse from environment variable
let preset: ThemePreset = "monokai".parse().unwrap();

Structs§

BoxStyle
Box drawing character sets for panels and tables.
BoxStyleParseError
Error parsing box style name.
Color
A color in RGB format.
FastApiTheme
FastAPI-inspired color theme for console output.
ThemeIcons
Icons used throughout the theme for visual feedback.
ThemePresetParseError
Error parsing theme preset name.
ThemeSpacing
Spacing values for consistent layout across components.

Enums§

BoxStylePreset
Preset for box style selection.
ThemePreset
Predefined theme presets.

Functions§

hex_to_rgb
Parse hex color to RGB tuple.
rgb_to_hex
Convert RGB tuple to hex string.