Tabs #
PhpTui\Tui\Extension\Core\Widget\TabsWidget
A widget that displays a horizontal set of Tabs with a single tab selected.
Each tab title is stored as a Line
which can be individually styled. The selected tab is set
using TabsWidget::select($n)
and styled using TabsWidget::highlightStyle(...)
. The divider can be customized
with TabsWidget::divider('|')
.
Example #
Show code
<?php
declare(strict_types=1);
use PhpTui\Tui\DisplayBuilder;
use PhpTui\Tui\Extension\Core\Widget\TabsWidget;
use PhpTui\Tui\Style\Style;
use PhpTui\Tui\Text\Line;
use PhpTui\Tui\Text\Span;
require 'vendor/autoload.php';
$display = DisplayBuilder::default()->build();
$display->draw(
TabsWidget::default()
->titles(
Line::fromString('Tab 0'),
Line::fromString('Tab 1'),
Line::fromString('Tab 3'),
)
->select(0)
->highlightStyle(Style::default()->white()->onRed())
->divider(Span::fromString('|'))
);
Parameters #
Configure the widget using the builder methods named as follows:
Name | Type | Description |
---|---|---|
titles | Line[] | |
selected | int<0, max> | |
style | PhpTui\Tui\Style\Style | |
highlightStyle | PhpTui\Tui\Style\Style | |
divider | PhpTui\Tui\Text\Span |