pub struct Row<'a> { /* private fields */ }
Expand description
A single row of data to be displayed in a Table
widget.
A Row
is a collection of Cell
s.
By default, a row has a height of 1 but you can change this using Row::height
.
You can set the style of the entire row using Row::style
. This Style
will be combined
with the Style
of each individual Cell
by adding the Style
of the Cell
to the
Style
of the Row
.
§Examples
You can create Row
s from simple strings.
use ratatui::{prelude::*, widgets::*};
Row::new(vec!["Cell1", "Cell2", "Cell3"]);
RunIf you need a bit more control over individual cells, you can explicitly create Cell
s:
use ratatui::{prelude::*, widgets::*};
Row::new(vec![
Cell::from("Cell1"),
Cell::from("Cell2").style(Style::default().fg(Color::Yellow)),
]);
RunYou can also construct a row from any type that can be converted into Text
:
use std::borrow::Cow;
use ratatui::{prelude::*, widgets::*};
Row::new(vec![
Cow::Borrowed("hello"),
Cow::Owned("world".to_uppercase()),
]);
RunAn iterator whose item type is convertible into Text
can be collected into a row.
use ratatui::widgets::Row;
(0..10).map(|i| format!("{i}")).collect::<Row>();
RunRow
implements Styled
which means you can use style shorthands from the Stylize
trait
to set the style of the row concisely.
use ratatui::{prelude::*, widgets::*};
let cells = vec!["Cell1", "Cell2", "Cell3"];
Row::new(cells).red().italic();
RunImplementations§
source§impl<'a> Row<'a>
impl<'a> Row<'a>
sourcepub fn new<T>(cells: T) -> Row<'a>
pub fn new<T>(cells: T) -> Row<'a>
Creates a new Row
The cells
parameter accepts any value that can be converted into an iterator of anything
that can be converted into a Cell
(e.g. Vec<&str>
, &[Cell<'a>]
, Vec<String>
, etc.)
§Examples
let row = Row::new(vec!["Cell 1", "Cell 2", "Cell 3"]);
let row = Row::new(vec![
Cell::new("Cell 1"),
Cell::new("Cell 2"),
Cell::new("Cell 3"),
]);
Runsourcepub fn cells<T>(self, cells: T) -> Row<'a>
pub fn cells<T>(self, cells: T) -> Row<'a>
Set the cells of the Row
The cells
parameter accepts any value that can be converted into an iterator of anything
that can be converted into a Cell
(e.g. Vec<&str>
, &[Cell<'a>]
, Vec<String>
, etc.)
This is a fluent setter method which must be chained or used as it consumes self
§Examples
let row = Row::default().cells(vec!["Cell 1", "Cell 2", "Cell 3"]);
let row = Row::default().cells(vec![
Cell::new("Cell 1"),
Cell::new("Cell 2"),
Cell::new("Cell 3"),
]);
Runsourcepub fn height(self, height: u16) -> Row<'a>
pub fn height(self, height: u16) -> Row<'a>
Set the fixed height of the Row
Any Cell
whose content has more lines than this height will see its content truncated.
By default, the height is 1
.
This is a fluent setter method which must be chained or used as it consumes self
§Examples
let cells = vec!["Cell 1\nline 2", "Cell 2", "Cell 3"];
let row = Row::new(cells).height(2);
Runsourcepub fn top_margin(self, margin: u16) -> Row<'a>
pub fn top_margin(self, margin: u16) -> Row<'a>
sourcepub fn bottom_margin(self, margin: u16) -> Row<'a>
pub fn bottom_margin(self, margin: u16) -> Row<'a>
sourcepub fn style<S>(self, style: S) -> Row<'a>
pub fn style<S>(self, style: S) -> Row<'a>
Set the Style
of the entire row
style
accepts any type that is convertible to Style
(e.g. Style
, Color
, or
your own type that implements Into<Style>
).
This Style
can be overridden by the Style
of a any individual Cell
or by their
Text
content.
This is a fluent setter method which must be chained or used as it consumes self
§Examples
let cells = vec!["Cell 1", "Cell 2", "Cell 3"];
let row = Row::new(cells).style(Style::new().red().italic());
RunRow
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.
let cells = vec!["Cell 1", "Cell 2", "Cell 3"];
let row = Row::new(cells).red().italic();
RunTrait Implementations§
source§impl<'a, Item> FromIterator<Item> for Row<'a>
impl<'a, Item> FromIterator<Item> for Row<'a>
source§impl<'a> PartialEq for Row<'a>
impl<'a> PartialEq for Row<'a>
impl<'a> Eq for Row<'a>
impl<'a> StructuralPartialEq for Row<'a>
Auto Trait Implementations§
impl<'a> RefUnwindSafe for Row<'a>
impl<'a> Send for Row<'a>
impl<'a> Sync for Row<'a>
impl<'a> Unpin for Row<'a>
impl<'a> UnwindSafe for Row<'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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§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(self, color: Color) -> T
fn fg<S>(self, color: S) -> 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.