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 |
gray
is sometimes calledwhite
- this is not supported as we usewhite
for bright whitegray
is sometimes calledsilver
- this is supporteddarkgray
is sometimes calledlight black
orbright black
(both are supported)white
is sometimes calledlight white
orbright white
(both are supported)- we support
bright
andlight
prefixes for all colors - we support
-
and_
andas separators for all colors
- we support both
gray
andgrey
spellings
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)
)
);