Skip to content

Commit 4188b0a

Browse files
committed
Minor tweak
1 parent 11d2537 commit 4188b0a

File tree

1 file changed

+33
-33
lines changed

1 file changed

+33
-33
lines changed

components/console/helpers/table.rst

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,39 @@ Here is a full list of things you can customize:
265265

266266
This method can also be used to override a built-in style.
267267

268+
.. versionadded:: 5.2
269+
270+
The option to style table cells was introduced in Symfony 5.2.
271+
272+
In addition to the built-in table styles, you can also apply different styles
273+
to each table cell via :class:`Symfony\\Component\\Console\\Helper\\TableCellStyle`::
274+
275+
use Symfony\Component\Console\Helper\Table;
276+
use Symfony\Component\Console\Helper\TableCellStyle;
277+
278+
$table = new Table($output);
279+
280+
$table->setRows([
281+
[
282+
'978-0804169127',
283+
new TableCell(
284+
'Divine Comedy',
285+
[
286+
'style' => new TableCellStyle([
287+
'align' => 'center',
288+
'fg' => 'red',
289+
'bg' => 'green',
290+
291+
// or
292+
'cellFormat' => '<info>%s</info>',
293+
])
294+
]
295+
)
296+
],
297+
]);
298+
299+
$table->render();
300+
268301
Spanning Multiple Columns and Rows
269302
----------------------------------
270303

@@ -393,36 +426,3 @@ This will display the following table in the terminal:
393426
| Love |
394427
| Symfony |
395428
+---------+
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)