List

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:

NameTypeDescription
itemsarray
stylePhpTui\Tui\Style\Style
startCornerPhpTui\Tui\Widget\Corner
highlightStylePhpTui\Tui\Style\Style
highlightSymbolstring
statePhpTui\Tui\Extension\Core\Widget\List\ListState
highlightSpacingPhpTui\Tui\Extension\Core\Widget\List\HighlightSpacing