mirror of
https://github.com/ratatui-org/ratatui
synced 2024-11-22 04:33:13 +00:00
docs(table): add documentation for block
and header
methods of the Table
widget (#505)
This commit is contained in:
parent
0c7d547db1
commit
dd9a8df03a
2 changed files with 42 additions and 0 deletions
|
@ -91,6 +91,7 @@
|
|||
//!
|
||||
//! [`TermionBackend`]: termion/struct.TermionBackend.html
|
||||
//! [`Terminal`]: crate::terminal::Terminal
|
||||
//! [`TermionBackend`]: termion/struct.TermionBackend.html
|
||||
//! [Crossterm]: https://crates.io/crates/crossterm
|
||||
//! [Termion]: https://crates.io/crates/termion
|
||||
//! [Termwiz]: https://crates.io/crates/termwiz
|
||||
|
|
|
@ -304,11 +304,52 @@ impl<'a> Table<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Creates a custom block around a [`Table`] widget.
|
||||
///
|
||||
/// The `block` parameter is of type [`Block`]. This holds the specified block to be
|
||||
/// created around the [`Table`]
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// # use ratatui::{prelude::*, widgets::*};
|
||||
/// let table = Table::new(vec![
|
||||
/// Row::new(vec![
|
||||
/// Cell::from("Cell1"),
|
||||
/// Cell::from("Cell2")
|
||||
/// ]),
|
||||
/// Row::new(vec![
|
||||
/// Cell::from("Cell3"),
|
||||
/// Cell::from("Cell4")
|
||||
/// ]),
|
||||
/// ]).block(Block::default().title("Table"));
|
||||
/// ```
|
||||
pub fn block(mut self, block: Block<'a>) -> Self {
|
||||
self.block = Some(block);
|
||||
self
|
||||
}
|
||||
|
||||
/// Creates a header for a [`Table`] widget.
|
||||
///
|
||||
/// The `header` parameter is of type [`Row`] and this holds the cells to be displayed at the
|
||||
/// top of the [`Table`]
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// # use ratatui::{prelude::*, widgets::*};
|
||||
/// let table = Table::new(vec![
|
||||
/// Row::new(vec![
|
||||
/// Cell::from("Cell1"),
|
||||
/// Cell::from("Cell2")
|
||||
/// ])
|
||||
/// ]).header(
|
||||
/// Row::new(vec![
|
||||
/// Cell::from("Header Cell 1"),
|
||||
/// Cell::from("Header Cell 2")
|
||||
/// ])
|
||||
/// );
|
||||
/// ```
|
||||
pub fn header(mut self, header: Row<'a>) -> Self {
|
||||
self.header = Some(header);
|
||||
self
|
||||
|
|
Loading…
Reference in a new issue