pub trait BlockExt<'a>: Sized {
// Required methods
fn apply_title(self, title: Title) -> Self;
fn title_alignment_horizontal(self, alignment: TitleAlignment) -> Self;
fn title_vertical_position(self, position: TitlePosition) -> Self;
}Expand description
Extension trait for adding title positioning helpers to Block.
This trait provides ergonomic methods for setting title alignment and position
on Ratatui’s Block type. It allows for method chaining and uses semantic
types instead of raw alignment values.
§Examples
§Using the unified Title API (recommended)
use tui_piechart::title::{Title, TitleStyle};
use ratatui::widgets::Block;
let styled = TitleStyle::Bold.apply("My Chart");
let block = Block::bordered()
.title(Title::new(styled).center().bottom());§Using individual positioning methods (legacy)
use tui_piechart::title::{TitleAlignment, TitlePosition, BlockExt};
use ratatui::widgets::Block;
let block = Block::bordered()
.title("My Chart")
.title_alignment_horizontal(TitleAlignment::Center)
.title_vertical_position(TitlePosition::Bottom);Required Methods§
Sourcefn apply_title(self, title: Title) -> Self
fn apply_title(self, title: Title) -> Self
Apply a unified Title with styling and positioning.
This is the recommended way to add styled and positioned titles.
§Examples
use tui_piechart::title::{Title, TitleStyle, BlockExt};
use ratatui::widgets::Block;
let styled = TitleStyle::Bold.apply("Stats");
let block = Block::bordered()
.apply_title(Title::new(styled).center().bottom());Sourcefn title_alignment_horizontal(self, alignment: TitleAlignment) -> Self
fn title_alignment_horizontal(self, alignment: TitleAlignment) -> Self
Sets the horizontal alignment of the title.
Controls whether the title appears at the start (left), center, or end (right) of the block border.
§Examples
use tui_piechart::title::{TitleAlignment, BlockExt};
use ratatui::widgets::Block;
let block = Block::bordered()
.title("My Chart")
.title_alignment_horizontal(TitleAlignment::Center);Sourcefn title_vertical_position(self, position: TitlePosition) -> Self
fn title_vertical_position(self, position: TitlePosition) -> Self
Sets the vertical position of the title.
Controls whether the title appears at the top or bottom of the block border.
§Examples
use tui_piechart::title::{TitlePosition, BlockExt};
use ratatui::widgets::Block;
let block = Block::bordered()
.title("My Chart")
.title_vertical_position(TitlePosition::Bottom);Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.