pub struct Cell<'a> { /* private fields */ }Expand description
A Cell contains the Text to be displayed in a Row of a Table.
You can apply a Style to the Cell using Cell::style. This will set the style for the
entire area of the cell. Any Style set on the Text content will be combined with the
Style of the Cell by adding the Style of the Text content to the Style of
the Cell. Styles set on the text content will only affect the content.
You can use Text::alignment when creating a cell to align its content.
§Examples
You can create a Cell from anything that can be converted to a Text.
use std::borrow::Cow;
use ratatui::{
style::Stylize,
text::{Line, Span, Text},
widgets::Cell,
};
Cell::from("simple string");
Cell::from(Span::from("span"));
Cell::from(Line::from(vec![
Span::from("a vec of "),
Span::from("spans").bold(),
]));
Cell::from(Text::from("a text"));
Cell::from(Text::from(Cow::Borrowed("hello")));Cell implements Styled which means you can use style shorthands from the Stylize trait
to set the style of the cell concisely.
use ratatui::{style::Stylize, widgets::Cell};
Cell::new("Cell 1").red().italic();Implementations§
Source§impl<'a> Cell<'a>
impl<'a> Cell<'a>
Sourcepub fn new<T>(content: T) -> Self
pub fn new<T>(content: T) -> Self
Creates a new Cell
The content parameter accepts any value that can be converted into a Text.
§Examples
use ratatui::{
style::Stylize,
text::{Line, Span, Text},
widgets::Cell,
};
Cell::new("simple string");
Cell::new(Span::from("span"));
Cell::new(Line::from(vec![
Span::raw("a vec of "),
Span::from("spans").bold(),
]));
Cell::new(Text::from("a text"));Sourcepub fn content<T>(self, content: T) -> Self
pub fn content<T>(self, content: T) -> Self
Set the content of the Cell
The content parameter accepts any value that can be converted into a Text.
This is a fluent setter method which must be chained or used as it consumes self
§Examples
use ratatui::{
style::Stylize,
text::{Line, Span, Text},
widgets::Cell,
};
Cell::default().content("simple string");
Cell::default().content(Span::from("span"));
Cell::default().content(Line::from(vec![
Span::raw("a vec of "),
Span::from("spans").bold(),
]));
Cell::default().content(Text::from("a text"));Sourcepub fn style<S: Into<Style>>(self, style: S) -> Self
pub fn style<S: Into<Style>>(self, style: S) -> Self
Set the Style of this cell
style accepts any type that is convertible to Style (e.g. Style, Color, or
your own type that implements Into<Style>).
This Style will override the Style of the Row and can be overridden by the Style
of the Text content.
This is a fluent setter method which must be chained or used as it consumes self
§Examples
use ratatui::{
style::{Style, Stylize},
widgets::Cell,
};
Cell::new("Cell 1").style(Style::new().red().italic());Cell also implements the Styled trait, which means you can use style shorthands from
the Stylize trait to set the style of the widget more concisely.
use ratatui::{style::Stylize, widgets::Cell};
Cell::new("Cell 1").red().italic();Trait Implementations§
impl<'a> Eq for Cell<'a>
impl<'a> StructuralPartialEq for Cell<'a>
Auto Trait Implementations§
impl<'a> Freeze for Cell<'a>
impl<'a> RefUnwindSafe for Cell<'a>
impl<'a> Send for Cell<'a>
impl<'a> Sync for Cell<'a>
impl<'a> Unpin for Cell<'a>
impl<'a> UnwindSafe for Cell<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<'a, T, U> Stylize<'a, T> for Uwhere
U: Styled<Item = T>,
impl<'a, T, U> Stylize<'a, T> for Uwhere
U: Styled<Item = T>,
fn bg<C>(self, color: C) -> T
fn fg<C>(self, color: C) -> T
fn add_modifier(self, modifier: Modifier) -> T
fn remove_modifier(self, modifier: Modifier) -> T
fn reset(self) -> T
Source§fn on_magenta(self) -> T
fn on_magenta(self) -> T
magenta.Source§fn on_dark_gray(self) -> T
fn on_dark_gray(self) -> T
dark_gray.Source§fn on_light_red(self) -> T
fn on_light_red(self) -> T
light_red.Source§fn light_green(self) -> T
fn light_green(self) -> T
light_green.Source§fn on_light_green(self) -> T
fn on_light_green(self) -> T
light_green.Source§fn light_yellow(self) -> T
fn light_yellow(self) -> T
light_yellow.Source§fn on_light_yellow(self) -> T
fn on_light_yellow(self) -> T
light_yellow.Source§fn light_blue(self) -> T
fn light_blue(self) -> T
light_blue.Source§fn on_light_blue(self) -> T
fn on_light_blue(self) -> T
light_blue.Source§fn light_magenta(self) -> T
fn light_magenta(self) -> T
light_magenta.Source§fn on_light_magenta(self) -> T
fn on_light_magenta(self) -> T
light_magenta.Source§fn light_cyan(self) -> T
fn light_cyan(self) -> T
light_cyan.Source§fn on_light_cyan(self) -> T
fn on_light_cyan(self) -> T
light_cyan.Source§fn not_italic(self) -> T
fn not_italic(self) -> T
ITALIC modifier.Source§fn underlined(self) -> T
fn underlined(self) -> T
UNDERLINED modifier.Source§fn not_underlined(self) -> T
fn not_underlined(self) -> T
UNDERLINED modifier.Source§fn slow_blink(self) -> T
fn slow_blink(self) -> T
SLOW_BLINK modifier.Source§fn not_slow_blink(self) -> T
fn not_slow_blink(self) -> T
SLOW_BLINK modifier.Source§fn rapid_blink(self) -> T
fn rapid_blink(self) -> T
RAPID_BLINK modifier.Source§fn not_rapid_blink(self) -> T
fn not_rapid_blink(self) -> T
RAPID_BLINK modifier.Source§fn not_reversed(self) -> T
fn not_reversed(self) -> T
REVERSED modifier.HIDDEN modifier.HIDDEN modifier.Source§fn crossed_out(self) -> T
fn crossed_out(self) -> T
CROSSED_OUT modifier.Source§fn not_crossed_out(self) -> T
fn not_crossed_out(self) -> T
CROSSED_OUT modifier.