Table Nunjucks macro options
Use options to customise the appearance, content and behaviour of this component when using a macro, for example, changing the text.
Also see the guidance on the Table component page, which shows these options in use within each example.
Some options are required for the macro to work; these are marked as "Required" in the option description. Deprecated options are marked as "Deprecated".
If you're using Nunjucks macros in production with "html" options, or ones ending with "html", you must sanitise the HTML to protect against cross-site scripting exploits.
| Name | Type | Description |
|---|---|---|
| rows | array | Required. The rows within the table component. See macro options for rows. |
| head | array |
Can be used to add a row of table header cells (<th>) at the top of the table component.
See macro options for head.
|
| caption | string | Caption text. |
| caption |
string | Classes for caption text size. Classes should correspond to the available typography heading classes. |
| first |
boolean |
If set to true, the first cell in each row will be a table header (<th>).
|
| classes | string | Classes to add to the table container. |
| attributes | object | HTML attributes (for example data attributes) to add to the table container. |
| Name | Type | Description |
|---|---|---|
| text | string |
Required.
If html is set, this is not required. Text for cells in table rows. If html is provided, the text option will be ignored.
|
| html | string |
Required.
If text is set, this is not required. HTML for cells in table rows. If html is provided, the text option will be ignored.
|
| format | string | Specify format of a cell. Currently we only use “numeric”. |
| classes | string | Classes to add to the table row cell. |
| colspan | integer | Specify how many columns a cell extends. |
| rowspan | integer | Specify how many rows a cell extends. |
| attributes | object | HTML attributes (for example data attributes) to add to the table cell. |
| Name | Type | Description |
|---|---|---|
| text | string |
If html is set, this is not required. Text for table head cells. If html is provided, the text option will be ignored.
|
| html | string |
If text is set, this is not required. HTML for table head cells. If html is provided, the text option will be ignored.
|
| format | string | Specify format of a cell. Currently we only use “numeric”. |
| classes | string | Classes to add to the table head cell. |
| colspan | integer | Specify how many columns a cell extends. |
| rowspan | integer | Specify how many rows a cell extends. |
| attributes | object | HTML attributes (for example data attributes) to add to the table cell. |