@@ -40,13 +40,22 @@ It is possible to define your own styles using the
40
40
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
41
41
42
42
// ...
43
- $outputStyle = new OutputFormatterStyle('red', 'yellow ', ['bold', 'blink']);
43
+ $outputStyle = new OutputFormatterStyle('red', '#ff0 ', ['bold', 'blink']);
44
44
$output->getFormatter()->setStyle('fire', $outputStyle);
45
45
46
46
$output->writeln('<fire>foo</>');
47
47
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 ``.
50
59
51
60
And available options are: ``bold ``, ``underscore ``, ``blink ``, ``reverse ``
52
61
(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::
59
68
// green text
60
69
$output->writeln('<fg=green>foo</>');
61
70
71
+ // red text
72
+ $output->writeln('<fg=#c0392b>foo</>');
73
+
62
74
// black text on a cyan background
63
75
$output->writeln('<fg=black;bg=cyan>foo</>');
64
76
0 commit comments