docs(paragraph): add docs for alignment fn (#467)

This commit is contained in:
onotaizee@gmail.com 2023-09-04 22:20:42 +01:00 committed by Josh McKinney
parent 343c6cdc47
commit 080a05bbd3
No known key found for this signature in database
GPG key ID: 722287396A903BC5

View file

@ -196,6 +196,20 @@ impl<'a> Paragraph<'a> {
self
}
/// Set the text alignment for the given paragraph
///
/// The alignment is a variant of the [`Alignment`] enum which can be one of Left, Right, or
/// Center.
///
/// # Example
///
/// ```rust
/// # use ratatui::prelude::*;
/// # use ratatui::widgets::{Paragraph, Wrap};
/// # use ratatui::layout::Alignment;
/// let paragraph = Paragraph::new("Hello World")
/// .alignment(Alignment::Center);
/// ```
pub fn alignment(mut self, alignment: Alignment) -> Paragraph<'a> {
self.alignment = alignment;
self