Skip to contents

Styles a table like one of the 122 surveyed sources listed by sdv_table_themes() ("datagolf", "wikipedia", "economist", ...). Fonts, ground, text and rule colors, row rules, column rules, striping, label case and tracking, and padding come from the theme's spec (table_theme_spec()).

Usage

gt_theme_source(gt_object, name, mode = "light", density = "comfortable")

Arguments

gt_object

A gt table object to modify.

name

A registry theme id, for example "datagolf" or "wikipedia".

mode

"light" (default) or "dark". "dark" on a light-only theme is an error that names three dark-capable themes in the same category.

density

Character. The type and padding scale. One of "comfortable" (the spec's own sizes), "compact" or "social".

Value

A modified gt table with the theme applied.

Details

The spec's sizes are the "comfortable" baseline; density rescales type and padding by the house density ratios, as the other gt_theme_*() functions do. Each face is a Google font written with its generic family ('Lora', serif), so a face that fails to load degrades to the right kind of font. The borders, stripes and tracking gt has no option for are written as css scoped to this table's id.

Examples

library(gt)
central <- subset(
  sdv_example_standings, division == "Central",
  c(team_name, wins, losses, win_pct)
)
gt(central) |> gt_theme_source("datagolf")
team_name wins losses win_pct
Detroit Pistons 60 22 0.732
Cleveland Cavaliers 52 30 0.634
Milwaukee Bucks 32 50 0.390
Chicago Bulls 31 51 0.378
Indiana Pacers 19 63 0.232
gt(central) |> gt_theme_source("datagolf", mode = "dark", density = "compact")
team_name wins losses win_pct
Detroit Pistons 60 22 0.732
Cleveland Cavaliers 52 30 0.634
Milwaukee Bucks 32 50 0.390
Chicago Bulls 31 51 0.378
Indiana Pacers 19 63 0.232