Config
The config block contains table-level metadata used for validation and rendering.
Fields
| Field | Type | Default | Description |
|---|---|---|---|
table_cols |
integer | required | Number of columns |
header_rows |
integer? | null |
Number of rows in thead, checked when given (ROW_COUNT) |
body_rows |
integer? | null |
Number of data rows across all row groups (summary rows not counted), checked when given |
stub_cols |
integer | 0 |
Number of stub (row label) columns, at the left |
row_striping |
boolean | false |
Stripe alternate data rows (below) |
row_striping_include_stub |
boolean | false |
Stripe the stub cells |
row_striping_include_body |
boolean | false |
Stripe the other cells |
column_labels_hidden |
boolean | false |
Leave out the column labels: every format draws an empty head |
table_width |
length? | null |
The table’s width: a length, or a % of the line (widths) |
container_width |
length? | null |
HTML: the most the container around the table is wide (max-width) |
container_height |
length? | null |
HTML: the most the container is high (max-height) |
container_overflow |
keyword? | null |
HTML: what the container does with a table that doesn’t fit (overflow: visible, hidden, clip, scroll or auto) |
locale |
string | "en-US" |
The locale the producer formatted values in. HTML takes its document’s lang from it when lang isn’t set |
lang |
string? | null |
The language of the table’s text, a BCP 47 tag (language and direction) |
dir |
keyword? | null |
"ltr", "rtl" or "auto": the direction its columns and text run in |
page_break_mode |
keyword | "avoid" |
How a paged format may break the table across pages: "avoid", "allow" or "force-between-groups" (below) |
aria_label |
string? | null |
HTML: the table’s accessible name (aria-label), in place of the title |
aria_describedby |
string? | null |
HTML: the ids of the elements that describe the table (aria-describedby), in place of the subtitle |
summary |
string? | null |
HTML: a <caption> for the table, which then names it in place of the title |
id |
string? | null |
The table’s id, as gt’s gt(id =) and Great Tables’ GT(id=): not empty and without whitespace (INVALID_TABLE_ID). HTML uses it as the writer’s table_id when that option isn’t set |
rules |
Rules? | null |
The table’s own rules, each in place of one of the default look’s (below) |
Row striping
With row_striping, even data rows (the 2nd, 4th, … counting across all row groups, as gt does) get a 5% gray background, rgba(128, 128, 128, 0.05). Stub cells are striped when row_striping_include_stub is set and other cells when row_striping_include_body is set, so with both flags off nothing is striped. Head and summary rows are never striped. Striping sits below conditional, row and cell styles in the style cascade, so any of them can override it. Formats without transparency show the stripe as it looks on white (#F9F9F9).
Language and direction
lang is the language the table’s text is in, as a BCP 47 tag ("ar", "fr-CA", "zh-Hant-TW"). It lets a format choose fonts, hyphenation and shaping for the text, and screen readers choose a voice. A value that isn’t a well-formed tag is an INVALID_LANG error. Unlike locale, which only sets how values were formatted, lang is written into the output.
dir is the direction the table runs in. With "rtl", the first column is on the right, text runs right to left, and lines outside the grid (the title, group labels, notes) start on the right. "auto" is right to left when the table’s first strongly directional character (in its title, labels and cells, in that order) is from a right-to-left script such as Arabic or Hebrew. HTML leaves that to the browser. "ltr" says left to right outright. Without dir, the table is left to right as before. The direction is never inferred from lang, so an Arabic-language table without dir still runs left to right.
Alignment and borders stay physical in either direction. A left-aligned column is aligned left and a cell’s left border is drawn on its left, wherever the cell ends up. To make a column start-aligned in a right-to-left table, align it right. How each format expresses this is listed under output formats.
{
"config": {
"table_cols": 3,
"header_rows": 1,
"body_rows": 4,
"lang": "ar",
"dir": "rtl"
}
}Page breaks
page_break_mode is a hint to the formats that lay out pages, as a writer may follow it only as far as its format can:
| Value | Meaning |
|---|---|
"avoid" |
Keep the table on one page, where the format can |
"allow" |
Break the table between rows where it doesn’t fit, repeating the column labels on each page |
"force-between-groups" |
Start each row group on a new page, repeating the column labels |
No writer reads it yet: each format breaks a table across pages as it does without it.
Rules
The formats that draw gridwell’s own rules (HTML, SVG and PPTX, with the rest of its look, and XLSX) put rules on the table: lines above and below the heading, under the column labels and the spanners, around group labels, between rows, after the stub, and above summary rows. rules changes them. Each field is a border whose width, style and color replace those of the default rule it names, so a field left out keeps the default. A style of none or hidden, or a width of 0, removes the rule. A double rule narrower than 3px is drawn solid, as CSS does. A value that isn’t valid is reported (INVALID_LENGTH, INVALID_COLOR, UNKNOWN_VALUE) and changes nothing.
| Field | Type | Default | Description |
|---|---|---|---|
title |
Border? | null |
Above the heading, when the table has one (default 2px solid #A8A8A8) |
top |
Border? | null |
The table’s top: under the heading, above the column labels (2px solid #D3D3D3) |
column_labels |
Border? | null |
Under the column labels (2px solid #D3D3D3) |
spanners |
Border? | null |
Under each spanner label (2px solid #D3D3D3) |
group |
Border? | null |
Above and below each group label (2px solid #D3D3D3) |
rows |
Border? | null |
Between body rows (1px solid #D3D3D3) |
stub |
Border? | null |
After the stub: right of it, or left in a right-to-left table (2px solid #D3D3D3) |
summary |
Border? | null |
Between a group’s summary rows and its data rows (2px solid #D3D3D3) |
grand_summary |
Border? | null |
Between the grand summary rows and the rows next to them (6px double #D3D3D3) |
bottom |
Border? | null |
The table’s bottom: above the footer (2px solid #D3D3D3) |
notes |
Border? | null |
Below the footer, when the table has one (2px solid #A8A8A8) |
Where two rules fall on one line, as the rule under a group’s label and the one above its summary rows when they are at the top, the wider is drawn, and of two as wide the stronger style (double, then solid, dashed and dotted), as CSS’s collapsed borders do. A cell’s own border still replaces the rule on its edge. The other formats draw rules of their own, so a table whose rules change the look is reported to them as the unsupported feature table-rules and drawn without the change.
{
"config": {
"table_cols": 3,
"header_rows": 1,
"body_rows": 4,
"rules": {
"top": { "width": "3px", "color": "#333333" },
"rows": { "style": "none" },
"bottom": { "width": "3px", "color": "#333333" }
}
}
}Example
{
"config": {
"table_cols": 5,
"header_rows": 2,
"body_rows": 10,
"stub_cols": 1,
"row_striping": true,
"row_striping_include_stub": true,
"row_striping_include_body": true,
"column_labels_hidden": false,
"table_width": "100%",
"container_width": "900px",
"locale": "en-US",
"page_break_mode": "avoid"
}
}body_rows counts data rows only — summary rows are not included. Both counts are optional: a producer that gives them has them checked. Stub columns must be contiguous starting from column 0.