List #
PhpTui\Tui\Extension\Core\Widget\ListWidget
The List widget allows you to list and highlight items.
Example #
Show code
<?php
declare(strict_types=1);
use PhpTui\Tui\DisplayBuilder;
use PhpTui\Tui\Extension\Core\Widget\List\ListItem;
use PhpTui\Tui\Extension\Core\Widget\List\ListState;
use PhpTui\Tui\Extension\Core\Widget\ListWidget;
use PhpTui\Tui\Text\Text;
require 'vendor/autoload.php';
$display = DisplayBuilder::default()->build();
$display->draw(
ListWidget::default()
->highlightSymbol('😼')
->state(new ListState(0, 2))
->items(
ListItem::new(Text::fromString('Item one')),
ListItem::new(Text::fromString('Item two')),
ListItem::new(Text::fromString('Item three')),
ListItem::new(Text::fromString('Item four')),
)
);
Parameters #
Configure the widget using the builder methods named as follows:
Name | Type | Description |
---|---|---|
items | array | |
style | PhpTui\Tui\Style\Style | |
startCorner | PhpTui\Tui\Widget\Corner | |
highlightStyle | PhpTui\Tui\Style\Style | |
highlightSymbol | string | |
state | PhpTui\Tui\Extension\Core\Widget\List\ListState | |
highlightSpacing | PhpTui\Tui\Extension\Core\Widget\List\HighlightSpacing |