File tree Expand file tree Collapse file tree 1 file changed +33
-33
lines changed
components/console/helpers Expand file tree Collapse file tree 1 file changed +33
-33
lines changed Original file line number Diff line number Diff 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+
268301Spanning 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();
You can’t perform that action at this time.
0 commit comments