Ansi Color #
PhpTui\Tui\Color\AnsiColor
All colors from the ANSI color table are supported (though some names are not exactly the same).
| Color Name | Color | Foreground | Background |
|---|---|---|---|
black | AnsiColor::Black | 30 | 40 |
red | AnsiColor::Red | 31 | 41 |
green | AnsiColor::Green | 32 | 42 |
yellow | AnsiColor::Yellow | 33 | 43 |
blue | AnsiColor::Blue | 34 | 44 |
magenta | AnsiColor::Magenta | 35 | 45 |
cyan | AnsiColor::Cyan | 36 | 46 |
gray* | AnsiColor::Gray | 37 | 47 |
darkgray* | AnsiColor::DarkGray | 90 | 100 |
lightred | AnsiColor::LightRed | 91 | 101 |
lightgreen | AnsiColor::LightGreen | 92 | 102 |
lightyellow | AnsiColor::LightYellow | 93 | 103 |
lightblue | AnsiColor::LightBlue | 94 | 104 |
lightmagenta | AnsiColor::LightMagenta | 95 | 105 |
lightcyan | AnsiColor::LightCyan | 96 | 106 |
white* | AnsiColor::White | 97 | 107 |
grayis sometimes calledwhite- this is not supported as we usewhitefor bright whitegrayis sometimes calledsilver- this is supporteddarkgrayis sometimes calledlight blackorbright black(both are supported)whiteis sometimes calledlight whiteorbright white(both are supported)- we support
brightandlightprefixes for all colors - we support
-and_andas separators for all colors - we support both
grayandgreyspellings
Example #
Show code
<?php
declare(strict_types=1);
use PhpTui\Tui\Color\AnsiColor;
use PhpTui\Tui\DisplayBuilder;
use PhpTui\Tui\Extension\Core\Widget\BlockWidget;
use PhpTui\Tui\Style\Style;
use PhpTui\Tui\Widget\Borders;
require 'vendor/autoload.php';
$display = DisplayBuilder::default()->build();
$display->draw(
BlockWidget::default()
->borders(Borders::ALL)
->style(
Style::default()
->fg(AnsiColor::Blue)
->bg(AnsiColor::Red)
)
);