Skip to main content

style

Function style 

Source
pub fn style(
    text: &str,
    fg: Option<Color>,
    bg: Option<Color>,
    bold: bool,
    dim: bool,
    underline: bool,
    overline: bool,
    italic: bool,
    blink: bool,
    strikethrough: bool,
    reset: bool,
) -> String
Expand description

Style text with ANSI escape codes.

Creates a styled string with the specified formatting. If the terminal doesn’t support colors or formatting is disabled, returns the text unchanged.

§Arguments

  • text - The text to style
  • fg - Foreground color
  • bg - Background color
  • bold - Bold text
  • dim - Dim (faint) text
  • underline - Underlined text
  • overline - Overlined text (not widely supported)
  • italic - Italic text
  • blink - Blinking text
  • strikethrough - Strikethrough text
  • reset - Whether to reset all styles at the end

§Returns

The styled string with ANSI escape codes.