Module style

Source
Expand description

This module contains a list of primitives which can be applied to change Table style.

§Style

It is responsible for a table border style. An individual cell border can be set by Border.

§Example

use tabled::{Table, settings::Style};

let data = vec!["Hello", "2022"];
let mut table = Table::new(&data);
table.with(Style::psql());

assert_eq!(
    table.to_string(),
    concat!(
        " &str  \n",
        "-------\n",
        " Hello \n",
        " 2022  ",
    )
)

§LineText

It’s used to override a border with a custom text.

§Example

use tabled::{
    Table, settings::{style::{LineText, Style}, object::Rows},
};

let data = vec!["Hello", "2022"];
let table = Table::new(&data)
    .with(Style::psql())
    .with(LineText::new("Santa", Rows::one(1)))
    .to_string();

assert_eq!(
    table,
    concat!(
        " &str  \n",
        "Santa--\n",
        " Hello \n",
        " 2022  ",
    )
)

§Border

Border can be used to modify cell’s borders.

It’s possible to set a collored border when color feature is on.

§Example

use tabled::{Table, settings::{Modify, Style, style::Border}};

let data = vec!["Hello", "2022"];
let table = Table::new(&data)
    .with(Style::psql())
    .modify((0, 0), Border::inherit(Style::modern()))
    .to_string();

assert_eq!(
    table,
    concat!(
        "┌───────┐\n",
        "│ &str  │\n",
        "└───────┘\n",
        "  Hello  \n",
        "  2022   ",
    )
)

§Theme

A different representation of Theme. With no checks in place.

It also contains a list of types to support colors.

Structs§

Border
Border represents a border of a Cell.
BorderColor
Border represents a border color of a Cell.
HorizontalLine
A horizontal split line which can be used to set a border.
LineChar
LineChar sets a char to a specific location on a horizontal line.
LineText
LineText writes a custom text on a border.
On
A marker struct which is used in Style.
Style
Style is represents a theme of a Table.
VerticalLine
A vertical split line which can be used to set a border.