Block #
PhpTui\Tui\Extension\Core\Widget\BlockWidget
Container for other widgets and can provide a border, title and padding.
Example #
Show code
<?php
declare(strict_types=1);
use PhpTui\Tui\DisplayBuilder;
use PhpTui\Tui\Extension\Core\Widget\BlockWidget;
use PhpTui\Tui\Extension\Core\Widget\ParagraphWidget;
use PhpTui\Tui\Text\Text;
use PhpTui\Tui\Text\Title;
use PhpTui\Tui\Widget\Borders;
use PhpTui\Tui\Widget\BorderType;
require 'vendor/autoload.php';
$display = DisplayBuilder::default()->build();
$display->draw(
BlockWidget::default()
->borders(Borders::ALL)
->titles(Title::fromString('Hello World'))
->borderType(BorderType::Rounded)
->widget(ParagraphWidget::fromText(Text::fromString('This is a block example')))
);
Parameters #
Configure the widget using the builder methods named as follows:
Name | Type | Description |
---|---|---|
borders | int | Bit mask which determines the border configuration, e.g. Borders::ALL |
titles | array | Titles for the block. You can have multiple titles and each title can be positioned in a different place. |
borderType | PhpTui\Tui\Widget\BorderType | Type of border, e.g. BorderType::Rounded |
borderStyle | PhpTui\Tui\Style\Style | Style of the border. |
style | PhpTui\Tui\Style\Style | Style of the block’s inner area. |
titleStyle | PhpTui\Tui\Style\Style | Style of the titles. |
padding | PhpTui\Tui\Extension\Core\Widget\Block\Padding | Padding to apply to the inner widget. |
widget | PhpTui\Tui\Widget\Widget|null | The inner widget. |