Skip to main content

toElement: a table as a DOM element

AFC, 2024
TeamQbWinsLosses
Patrick Mahomes152
Justin Herbert116
Bo Nix107
Gardner Minshew413
Josh Allen134
Tua Tagovailoa89
Aaron Rodgers512
Drake Maye413
import { STANDINGS, type Standing } from "@sportsdataverse/examples/data";
import { defineTable } from "@sportsdataverse/sdvtables";
import { prepare, toElement } from "@sportsdataverse/sdvtables/html";

// toElement needs a DOM (a browser, jsdom or happy-dom); it moves the theme's font <link> into <head> once.
const spec = defineTable<Standing>()
.columns((c) => [c.logo("team", { league: "nfl" }), c.text("qb"), c.int("wins"), c.int("losses")])
.theme("pl")
.title("AFC, 2024")
.build();
await prepare(spec);
toElement(spec, STANDINGS);

Tags: table · toElement · dom · nfl. All sdvtables examples.