Skip to content

Commit 7f464ac

Browse files
committed
feature #14494 Mention supported hex colors (freezy-sk)
This PR was squashed before being merged into the 5.2-dev branch. Discussion ---------- Mention supported hex colors Mention supported hex colors for foreground and background Fixes #13795 Commits ------- 64058aa Mention supported hex colors
2 parents 3d2e90e + 64058aa commit 7f464ac

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

console/coloring.rst

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

5160
And 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

Comments
 (0)