Skip to main content

themePreview: one table under several themes

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");

Tags: table · themePreview · gt_theme_preview · theme · nfl. All sdvtables examples.