Skip to content

Mention supported hex colors #14494

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 30, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions console/coloring.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,22 @@ It is possible to define your own styles using the
use Symfony\Component\Console\Formatter\OutputFormatterStyle;

// ...
$outputStyle = new OutputFormatterStyle('red', 'yellow', ['bold', 'blink']);
$outputStyle = new OutputFormatterStyle('red', '#ff0', ['bold', 'blink']);
$output->getFormatter()->setStyle('fire', $outputStyle);

$output->writeln('<fire>foo</>');

Available foreground and background colors are: ``black``, ``red``, ``green``,
``yellow``, ``blue``, ``magenta``, ``cyan`` and ``white``.
Any hex color is supported for foreground and background colors. Besides that, these named colors are supported:
``black``, ``red``, ``green``, ``yellow``, ``blue``, ``magenta``, ``cyan`` and ``white``.

.. versionadded:: 5.2

True (hex) color support was introduced in Symfony 5.2

.. note::

If the terminal doesn't support true colors, the nearest named color is used.
E.g. ``#c0392b`` is degraded to ``red`` or ``#f1c40f`` is degraded to ``yellow``.

And available options are: ``bold``, ``underscore``, ``blink``, ``reverse``
(enables the "reverse video" mode where the background and foreground colors
Expand All @@ -59,6 +68,9 @@ You can also set these colors and options directly inside the tag name::
// green text
$output->writeln('<fg=green>foo</>');

// red text
$output->writeln('<fg=#c0392b>foo</>');

// black text on a cyan background
$output->writeln('<fg=black;bg=cyan>foo</>');

Expand Down