pub struct Title<'a> {
pub content: Line<'a>,
pub alignment: Option<Alignment>,
pub position: Option<Position>,
}Expand description
A Block title.
It can be aligned (see Alignment) and positioned (see Position).
§Future Deprecation
This type is deprecated and will be removed in a future release. The reason for this is that the
position of the title should be stored in the block itself, not in the title. The Line type
has an alignment method that can be used to align the title. For more information see
https://github.com/ratatui/ratatui/issues/738.
Use Line instead, when the position is not defined as part of the title. When a specific
position is needed, use Block::title_top or
Block::title_bottom instead.
§Example
Title with no style.
use ratatui::widgets::block::Title;
Title::from("Title");Blue title on a white background (via Stylize trait).
use ratatui::{style::Stylize, widgets::block::Title};
Title::from("Title".blue().on_white());Title with multiple styles (see Line and Stylize).
use ratatui::{style::Stylize, text::Line, widgets::block::Title};
Title::from(Line::from(vec!["Q".white().underlined(), "uit".gray()]));Complete example
use ratatui::{
layout::Alignment,
widgets::{
block::{Position, Title},
Block,
},
};
Title::from("Title")
.position(Position::Top)
.alignment(Alignment::Right);Fields§
§content: Line<'a>Title content
alignment: Option<Alignment>Title alignment
If None, defaults to the alignment defined with
Block::title_alignment in the associated
Block.
position: Option<Position>Title position
If None, defaults to the position defined with
Block::title_position in the associated
Block.
Implementations§
Source§impl<'a> Title<'a>
impl<'a> Title<'a>
Sourcepub fn content<T>(self, content: T) -> Self
👎Deprecated: use Block::title_top() or Block::title_bottom() instead. This will be removed in a future release.
pub fn content<T>(self, content: T) -> Self
Set the title content.
Trait Implementations§
impl<'a> Eq for Title<'a>
impl<'a> StructuralPartialEq for Title<'a>
Auto Trait Implementations§
impl<'a> Freeze for Title<'a>
impl<'a> RefUnwindSafe for Title<'a>
impl<'a> Send for Title<'a>
impl<'a> Sync for Title<'a>
impl<'a> Unpin for Title<'a>
impl<'a> UnwindSafe for Title<'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 more