Skip to main content

Table themes

info

The table theme registry lists 122 themes named after their source, usable in sdvtables, sdvplot and sdvplotR.

A theme sets everything about a table that is not its data: fonts, colours, rules, spacing. sdvtables ships its house themes (the 20 of sdvplotR and gtUtils) and the 27 of reactablefmtr, each one function call on the builder, so a table can match a site, a publication or a team without any CSS of your own. The theme gallery shows every one on the same rows; the sources surveyed beyond these are in the registry.

One theme​

.theme(name) picks a theme by name. Most themes load their Google Fonts with the table.

AFC, 2024 regular season
TeamWinsLossesPFPANet EPA/play
1523853260.063
1164023010.101
1074253110.108
413309434-0.146
1345253680.190
89345364-0.019
512338404-0.045
413289417
import { STANDINGS } from "@sportsdataverse/examples/data";
import { defineTable } from "@sportsdataverse/sdvtables";
import { renderHTMLAsync } from "@sportsdataverse/sdvtables/html";

const spec = defineTable<(typeof STANDINGS)[number]>()
.columns((c) => [
c.logo("team", { league: "nfl" }),
c.int("wins"),
c.int("losses"),
c.int("pf", { label: "PF" }),
c.int("pa", { label: "PA" }),
c.colorPills("net_epa", { label: "Net EPA/play", digits: 3, domain: [-0.2, 0.2] }),
])
.theme("midnight")
.title("AFC, 2024 regular season")
.build();
await renderHTMLAsync(spec, STANDINGS);

A team's own colours​

sdvTeam fills the header with a team's primary colour: pass { league, team } as its options. The title takes onColor of the fill, and the subtitle secondaryOn, a blend of the title ink toward the fill that still reads at 4.5:1.

AFC, 2024 regular season
TeamWinsLossesPFPANet EPA/play
1523853260.063
1164023010.101
1074253110.108
413309434-0.146
1345253680.190
89345364-0.019
512338404-0.045
413289417
import { STANDINGS } from "@sportsdataverse/examples/data";
import { defineTable } from "@sportsdataverse/sdvtables";
import { renderHTMLAsync } from "@sportsdataverse/sdvtables/html";

const spec = defineTable<(typeof STANDINGS)[number]>()
.columns((c) => [
c.logo("team", { league: "nfl" }),
c.int("wins"),
c.int("losses"),
c.int("pf", { label: "PF" }),
c.int("pa", { label: "PA" }),
c.colorPills("net_epa", { label: "Net EPA/play", digits: 3, domain: [-0.2, 0.2] }),
])
.theme("sdvTeam", { options: { league: "nfl", team: "KC" } })
.title("AFC, 2024 regular season")
.build();
await renderHTMLAsync(spec, STANDINGS);
Kansas City, sdvTeamEach row: the header inks sdvTeam would pick for that team
TeamPrimaryTitle InkSubtitle Ink
KC#e31837#ffffff#ffffff
LAC#007bc7#000000#00060a
DEN#002244#ffffff#8090a2
LV#000000#ffffff#808080
BUF#00338d#ffffff#99add1
MIA#008e97#000000#001517
NYJ#003f2d#ffffff#8ca9a0
NE#002244#ffffff#8090a2
import { STANDINGS } from "@sportsdataverse/examples/data";
import { loadLeague, onColor, teamColorsSync } from "@sportsdataverse/sdvplot";
import { defineTable, secondaryOn } from "@sportsdataverse/sdvtables";
import { renderHTMLAsync } from "@sportsdataverse/sdvtables/html";

// sdvTeam fills the header with the team's primary colour. The title takes onColor(primary); the subtitle takes
// secondaryOn(primary, title ink): the title ink blended toward the fill as far as it still reads at 4.5:1.
await loadLeague("nfl");
const rows = STANDINGS.map((r) => {
const primary = teamColorsSync("nfl", r.team) ?? "#0B1A33";
const title = onColor(primary);
return { team: r.team, primary, title_ink: title, subtitle_ink: secondaryOn(primary, title) };
});
const spec = defineTable<(typeof rows)[number]>()
.columns((c) => [
c.teamColorBar("team", { league: "nfl", barWidth: 8 }),
c.text("primary"),
c.text("title_ink"),
c.text("subtitle_ink"),
])
.theme("sdvTeam", { options: { league: "nfl", team: "KC" } })
.title("Kansas City, sdvTeam")
.subtitle("Each row: the header inks sdvTeam would pick for that team")
.build();
await renderHTMLAsync(spec, rows);

reactablefmtr themes​

The 27 themes of reactablefmtr are registered as fmtr-<name> (fmtr-espn, fmtr-nytimes, fmtr-fivethirtyeight, ...), so they never collide with the house themes: the house midnight and reactablefmtr's fmtr-midnight are different tables. no_lines is fmtr-no-lines, and GT_ALIASES maps each reactablefmtr name to its theme. Colours, sizes, rules and padding are reactablefmtr's own, read from its source. Where a reactablefmtr colour is not readable, readable wins: sdvtables gates the reactablefmtr themes at 4.5:1 for text (header labels, group headings, and body type on the ground, every gradient stop, and the stripe and hover fills) and at 3:1 for the row cues and the filter boxes, and moves a failing colour only as far as it must, keeping its hue. The body type of espn, lux, minty, pff and spacelab and the stripe and hover fill of midnight were moved for the 3:1 cues; the text moves are:

ThemeColourreactablefmtrsdvtablesRatio before → after
ceruleanheader fill (under #cfe9f7 labels)#3ba9e8#136c9f2.07 → 4.53
cyborgbody (on the stripe)#888888#8e8e8e4.16 → 4.50
darklyheader label#afbdcc#c5cfda3.74 → 4.54
darklystripe / hover fill (white type)#adb5bd#70777e2.07 → 4.54
hoverlightstripe / hover fill (white type)#d3d3d3#7676761.50 → 4.54
journalheader fill (under #fad9d8 labels)#ef8683#c41e191.90 → 4.51
luxheader label#7f7f7f#8282824.35 → 4.53
midnightbody and group heading#727272#8181813.65 → 4.51
midnightheader label#666666#7575753.66 → 4.56
mintyheader fill (under #c9e7de labels)#78c2ad#326e5d1.58 → 4.53
nytimesheader label#999999#7676762.85 → 4.54
pffgroup heading#878e94#63696f2.70 → 4.51
sandstoneheader label#7c7a78#72706e3.93 → 4.53
slateheader label#97999b#a7a9ab3.72 → 4.51
slatebody (on the stripe)#aaaaaa#b8b8b83.85 → 4.51
spacelabheader label#8e8e8e#6b6b6b2.80 → 4.55
sunriseheader label#8069ff#6b51ff3.58 → 4.54
sunrisebody (on the #f98d77 gradient stop)#8069ff#4034801.69 → 4.51

On cerulean, journal and minty no lighter tint of the light header labels reaches 4.5:1, so the labels keep reactablefmtr's colour and the header fill darkens in its own hue instead. Ratios before are reactablefmtr's own colours on the same ground. reactablefmtr's column-group header styles (espn's rules, pff's band, fivethirtyeight's uppercase) dress sdvtables' row-group headings, its only group header. Not ported: the hover and sort colours of the header labels, reactable's 8px inset of the group heading's rule, and &:not(:empty) (sdvtables never renders an empty group heading).

AFC, 2024 regular season
TeamWinsLossesPFPANet EPA/play
1523853260.063
1164023010.101
1074253110.108
413309434-0.146
1345253680.190
89345364-0.019
512338404-0.045
413289417
import { STANDINGS } from "@sportsdataverse/examples/data";
import { defineTable } from "@sportsdataverse/sdvtables";
import { renderHTMLAsync } from "@sportsdataverse/sdvtables/html";

const spec = defineTable<(typeof STANDINGS)[number]>()
.columns((c) => [
c.logo("team", { league: "nfl" }),
c.int("wins"),
c.int("losses"),
c.int("pf", { label: "PF" }),
c.int("pa", { label: "PA" }),
c.colorPills("net_epa", { label: "Net EPA/play", digits: 3, domain: [-0.2, 0.2] }),
])
.theme("fmtr-espn")
.title("AFC, 2024 regular season")
.build();
await renderHTMLAsync(spec, STANDINGS);

Each theme function's arguments are options: fontSize, fontColor, headerFontSize, headerFontColor, backgroundColor and cellPadding. reactable's striped and highlight are options too ("true"), off by default as in reactable. The highlight fills the row under the pointer (the engine's hovered row), and is on by default in fmtr-hoverdark and fmtr-hoverlight.

fmtr-nytimes, as shipped
TeamWinsLosses
152
116
107
413
fmtr-nytimes, striped: "true", fontSize: "14"
TeamWinsLosses
152
116
107
413
import { STANDINGS, type Standing } from "@sportsdataverse/examples/data";
import { defineTable } from "@sportsdataverse/sdvtables";
import { renderHTMLAsync } from "@sportsdataverse/sdvtables/html";

// A reactablefmtr theme function's arguments are the theme's options; reactable's striped and highlight are too.
const variants = [
{ label: "as shipped", options: {} },
{ label: 'striped: "true", fontSize: "14"', options: { striped: "true", fontSize: "14" } },
];
const tables = await Promise.all(
variants.map(({ label, options }) =>
renderHTMLAsync(
defineTable<Standing>()
.columns((c) => [c.logo("team", { league: "nfl" }), c.int("wins"), c.int("losses")])
.theme("fmtr-nytimes", { options })
.title(`fmtr-nytimes, ${label}`)
.build(),
STANDINGS.slice(0, 4),
),
),
);
tables.join("\n");

fmtr-team is reactablefmtr's default look with the header filled in a team's primary colour ({ league, team }), the header ink picked by contrast, a rule in the secondary colour, and stripe and hover tints that keep the body type at 4.5:1.

AFC, 2024 regular season
TeamWinsLossesPFPANet EPA/play
1523853260.063
1164023010.101
1074253110.108
413309434-0.146
1345253680.190
89345364-0.019
512338404-0.045
413289417
import { STANDINGS } from "@sportsdataverse/examples/data";
import { defineTable } from "@sportsdataverse/sdvtables";
import { renderHTMLAsync } from "@sportsdataverse/sdvtables/html";

const spec = defineTable<(typeof STANDINGS)[number]>()
.columns((c) => [
c.logo("team", { league: "nfl" }),
c.int("wins"),
c.int("losses"),
c.int("pf", { label: "PF" }),
c.int("pa", { label: "PA" }),
c.colorPills("net_epa", { label: "Net EPA/play", digits: 3, domain: [-0.2, 0.2] }),
])
.theme("fmtr-team", { options: { league: "nfl", team: "KC" } })
.title("AFC, 2024 regular season")
.build();
await renderHTMLAsync(spec, STANDINGS);

FMTR_THEME_NAMES lists the 27; hand it to themePreview to see them side by side.

import { STANDINGS, type Standing } from "@sportsdataverse/examples/data";
import { FMTR_THEME_NAMES, defineTable } from "@sportsdataverse/sdvtables";
import { prepare, themePreview } from "@sportsdataverse/sdvtables/html";

const spec = defineTable<Standing>()
.columns((c) => [
c.logo("team", { league: "nfl" }),
c.int("wins"),
c.int("losses"),
c.num("net_epa", { digits: 3 }),
])
.title("AFC, 2024")
.build();
await prepare(spec);
// FMTR_THEME_NAMES lists fmtr-cerulean ... fmtr-void; themePreview renders the first n rows under each, compact.
const previews = themePreview(spec, STANDINGS, FMTR_THEME_NAMES, { n: 3 });
Object.entries(previews)
.map(([name, html]) => `<h4>${name}</h4>\n${html}`)
.join("\n");

Density​

.theme(name, { density }) scales type and padding from DENSITY: compact, comfortable or social.

density: "compact"body 12px, cell padding 3px
TeamWinsLosses
152
116
107
density: "comfortable"body 14px, cell padding 6px
TeamWinsLosses
152
116
107
density: "social"body 17px, cell padding 9px
TeamWinsLosses
152
116
107
import { STANDINGS, type Standing } from "@sportsdataverse/examples/data";
import { DENSITY, type Density, defineTable } from "@sportsdataverse/sdvtables";
import { renderHTMLAsync } from "@sportsdataverse/sdvtables/html";

// .theme(name, { density }) scales type and padding from DENSITY; almanac, scoreboard and terminal default to compact.
const densities: Density[] = ["compact", "comfortable", "social"];
const tables = await Promise.all(
densities.map((density) =>
renderHTMLAsync(
defineTable<Standing>()
.columns((c) => [c.logo("team", { league: "nfl" }), c.int("wins"), c.int("losses")])
.theme("sdv", { density })
.title(`density: "${density}"`)
.subtitle(`body ${DENSITY[density].body}px, cell padding ${DENSITY[density].pad}px`)
.build(),
STANDINGS.slice(0, 3),
),
),
);
tables.join("\n");

Comparing themes​

themePreview(spec, rows, names) renders one table per theme (every theme when names is left out), for choosing one.

TeamWinsLosses
KC152
BUF134
TeamWinsLosses
KC152
BUF134
TeamWinsLosses
KC152
BUF134
import { defineTable } from "@sportsdataverse/sdvtables";
import { themePreview } from "@sportsdataverse/sdvtables/html";

const rows = [
{ team: "KC", wins: 15, losses: 2 },
{ team: "BUF", wins: 13, losses: 4 },
];
const spec = defineTable<(typeof rows)[number]>()
.columns((c) => [c.text("team"), c.int("wins"), c.int("losses")])
.build();
Object.values(themePreview(spec, rows, ["sdv", "athletic", "midnight"])).join("\n");

sdv

AFC, 2024
TeamWinsLosses
152
116
107

midnight

AFC, 2024
TeamWinsLosses
152
116
107

tufte

AFC, 2024
TeamWinsLosses
152
116
107

scoreboard

AFC, 2024
TeamWinsLosses
152
116
107
import { STANDINGS, type Standing } from "@sportsdataverse/examples/data";
import { defineTable } from "@sportsdataverse/sdvtables";
import { prepare, themePreview } from "@sportsdataverse/sdvtables/html";

const spec = defineTable<Standing>()
.columns((c) => [c.logo("team", { league: "nfl" }), c.int("wins"), c.int("losses")])
.title("AFC, 2024")
.build();
await prepare(spec);
// One HTML string per theme (all 20 when the list is left out), the first n rows, compact.
const previews = themePreview(spec, STANDINGS, ["sdv", "midnight", "tufte", "scoreboard"], { n: 3 });
Object.entries(previews)
.map(([name, html]) => `<h4>${name}</h4>\n${html}`)
.join("\n");

The registry​

THEMES maps each name in THEME_NAMES to the function that builds it, and resolveTheme picks and calls one. A theme's tokens (TOKEN_KEYS) become CSS custom properties on the table.

{
  "THEME_NAMES": [
    "sdv",
    "sdvTeam",
    "almanac",
    "athletic",
    "booktabs",
    "broadsheet",
    "brutalist",
    "drench",
    "gtutils",
    "kenpom",
    "midnight",
    "ncaa",
    "pl",
    "savant",
    "scoreboard",
    "sofa",
    "swiss",
    "terminal",
    "tier",
    "tufte",
    "fmtr-cerulean",
    "fmtr-clean",
    "fmtr-cosmo",
    "fmtr-cyborg",
    "fmtr-dark",
    "fmtr-darkly",
    "fmtr-default",
    "fmtr-espn",
    "fmtr-fivethirtyeight",
    "fmtr-flatly",
    "fmtr-hoverdark",
    "fmtr-hoverlight",
    "fmtr-journal",
    "fmtr-lux",
    "fmtr-midnight",
    "fmtr-midnightblue",
    "fmtr-minty",
    "fmtr-no-lines",
    "fmtr-nytimes",
    "fmtr-pff",
    "fmtr-sandstone",
    "fmtr-sanfran",
    "fmtr-slate",
    "fmtr-spacelab",
    "fmtr-sunrise",
    "fmtr-superhero",
    "fmtr-void",
    "fmtr-team"
  ],
  "THEMES.midnight is a function": true,
  "TOKEN_KEYS.length": 53,
  "midnight colour tokens": {
    "bg": "#0C0D10",
    "text": "#E8E9ED",
    "muted": "#9498A3",
    "accent": "#5b8def",
    "rule": "#24272E",
    "stripe": "transparent"
  },
  "midnight fonts": [
    "Chivo"
  ],
  "PAL_MIDNIGHT": [
    "#5B8DEF",
    "#3FBF87",
    "#E8E9ED",
    "#9498A3",
    "#24272E"
  ]
}
import { PAL_MIDNIGHT, THEMES, THEME_NAMES, TOKEN_KEYS, resolveTheme } from "@sportsdataverse/sdvtables";

// A theme is a function of { name, density, options } (THEMES[name]); resolveTheme picks and calls it.
// Its tokens (TOKEN_KEYS) become CSS custom properties on the table.
const midnight = resolveTheme({ name: "midnight", density: "comfortable" });
const { bg, text, muted, accent, rule, stripe } = midnight.tokens;

{
THEME_NAMES,
"THEMES.midnight is a function": typeof THEMES.midnight === "function",
"TOKEN_KEYS.length": TOKEN_KEYS.length,
"midnight colour tokens": { bg, text, muted, accent, rule, stripe },
"midnight fonts": midnight.fonts.map((f) => f.family),
PAL_MIDNIGHT,
};

In the gallery: Every theme and Theme API.