Skip to content

Commit 11d2537

Browse files
committed
minor #14084 [Console] added TableCellStyle documentation (khoptynskyi)
This PR was merged into the master branch. Discussion ---------- [Console] added TableCellStyle documentation See symfony/symfony#37338 Commits ------- 4a5be12 [Console] added TableCellStyle documentation
2 parents 5aef4a5 + 4a5be12 commit 11d2537

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

components/console/helpers/table.rst

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,3 +393,36 @@ This will display the following table in the terminal:
393393
| Love |
394394
| Symfony |
395395
+---------+
396+
397+
.. versionadded:: 5.2
398+
399+
Styling of table cells
400+
----------------------
401+
402+
You can customize a table cell via :class:`Symfony\\Component\\Console\\Helper\\TableCellStyle`::
403+
404+
use Symfony\Component\Console\Helper\Table;
405+
use Symfony\Component\Console\Helper\TableCellStyle;
406+
407+
$table = new Table($output);
408+
409+
$table->setRows([
410+
[
411+
'978-0804169127',
412+
new TableCell(
413+
'Divine Comedy',
414+
[
415+
'style' => new TableCellStyle([
416+
'align' => 'center',
417+
'fg' => 'red',
418+
'bg' => 'green',
419+
420+
// or
421+
'cellFormat' => '<info>%s</info>',
422+
])
423+
]
424+
)
425+
],
426+
]);
427+
428+
$table->render();

0 commit comments

Comments
 (0)