@@ -40,13 +40,22 @@ It is possible to define your own styles using the
4040 use Symfony\Component\Console\Formatter\OutputFormatterStyle;
4141
4242 // ...
43- $outputStyle = new OutputFormatterStyle('red', 'yellow ', ['bold', 'blink']);
43+ $outputStyle = new OutputFormatterStyle('red', '#ff0 ', ['bold', 'blink']);
4444 $output->getFormatter()->setStyle('fire', $outputStyle);
4545
4646 $output->writeln('<fire>foo</>');
4747
48- Available foreground and background colors are: ``black ``, ``red ``, ``green ``,
49- ``yellow ``, ``blue ``, ``magenta ``, ``cyan `` and ``white ``.
48+ Any hex color is supported for foreground and background colors. Besides that, these named colors are supported:
49+ ``black ``, ``red ``, ``green ``, ``yellow ``, ``blue ``, ``magenta ``, ``cyan `` and ``white ``.
50+
51+ .. versionadded :: 5.2
52+
53+ True (hex) color support was introduced in Symfony 5.2
54+
55+ .. note ::
56+
57+ If the terminal doesn't support true colors, the nearest named color is used.
58+ E.g. ``#c0392b `` is degraded to ``red `` or ``#f1c40f `` is degraded to ``yellow ``.
5059
5160And available options are: ``bold ``, ``underscore ``, ``blink ``, ``reverse ``
5261(enables the "reverse video" mode where the background and foreground colors
@@ -59,6 +68,9 @@ You can also set these colors and options directly inside the tag name::
5968 // green text
6069 $output->writeln('<fg=green>foo</>');
6170
71+ // red text
72+ $output->writeln('<fg=#c0392b>foo</>');
73+
6274 // black text on a cyan background
6375 $output->writeln('<fg=black;bg=cyan>foo</>');
6476
0 commit comments