feat: adds block padding example

pull/551/head
Igor Mandello 3 years ago
parent 39f2bbed03
commit 3f9ef72165

@ -9,7 +9,7 @@ use tui::{
layout::{Alignment, Constraint, Direction, Layout},
style::{Color, Modifier, Style},
text::Span,
widgets::{Block, BorderType, Borders},
widgets::{Block, BorderType, Borders, Paragraph},
Terminal,
};
@ -79,16 +79,30 @@ fn main() -> Result<(), Box<dyn Error>> {
.split(chunks[1]);
// Bottom left block with all default borders
let block = Block::default().title("With borders").borders(Borders::ALL);
f.render_widget(block, bottom_chunks[0]);
let block = Block::default()
.title("With borders")
.borders(Borders::ALL)
.vertical_padding(2)
.horizontal_padding(4);
let text = Paragraph::new("text inside padded block").block(block);
f.render_widget(text, bottom_chunks[0]);
// Bottom right block with styled left and right border
let block = Block::default()
.title("With styled borders and doubled borders")
.border_style(Style::default().fg(Color::Cyan))
.borders(Borders::LEFT | Borders::RIGHT)
.border_type(BorderType::Double);
.border_type(BorderType::Double)
.padding(1);
let inner_block = Block::default()
.title("Block inside padded block")
.borders(Borders::ALL);
let inner_area = block.inner(bottom_chunks[1]);
f.render_widget(block, bottom_chunks[1]);
f.render_widget(inner_block, inner_area);
})?;
if let Event::Input(key) = events.next()? {

Loading…
Cancel
Save