pub trait StyledText {
// Required methods
fn style(self, style_name: &str, tcss: &Termio) -> StyledString;
fn color(self, color: Color) -> StyledString;
fn bg(self, color: Color) -> StyledString;
fn decoration(self, decoration: Decoration) -> StyledString;
fn padding(self, padding: u8) -> StyledString;
fn padding_trbl(
self,
top: u8,
right: u8,
bottom: u8,
left: u8,
) -> StyledString;
fn margin(self, margin: u8) -> StyledString;
fn border(self, style: BorderStyle) -> StyledString;
fn border_color(self, color: Color) -> StyledString;
}Expand description
A trait for text that can be styled using Termio.
This trait provides methods for applying styles to text elements.
It is implemented for String and &str.
§Examples
use terminal_css::StyledText;
use terminal_css::Termio;
let tcss = Termio::from_file("examples/styles.tcss").unwrap();
let text = "Hello, World!".style("header", &tcss);
Required Methods§
Sourcefn style(self, style_name: &str, tcss: &Termio) -> StyledString
fn style(self, style_name: &str, tcss: &Termio) -> StyledString
Sourcefn color(self, color: Color) -> StyledString
fn color(self, color: Color) -> StyledString
Set text color
Sourcefn bg(self, color: Color) -> StyledString
fn bg(self, color: Color) -> StyledString
Set background color
Sourcefn decoration(self, decoration: Decoration) -> StyledString
fn decoration(self, decoration: Decoration) -> StyledString
Add decoration
Sourcefn padding(self, padding: u8) -> StyledString
fn padding(self, padding: u8) -> StyledString
Set padding (all sides)
Sourcefn padding_trbl(self, top: u8, right: u8, bottom: u8, left: u8) -> StyledString
fn padding_trbl(self, top: u8, right: u8, bottom: u8, left: u8) -> StyledString
Set padding for top, right, bottom, left
Sourcefn margin(self, margin: u8) -> StyledString
fn margin(self, margin: u8) -> StyledString
Set margin (all sides)
Sourcefn border(self, style: BorderStyle) -> StyledString
fn border(self, style: BorderStyle) -> StyledString
Set border style
Sourcefn border_color(self, color: Color) -> StyledString
fn border_color(self, color: Color) -> StyledString
Set border color