Skip to contents

Builds the table on whitespace. There are no fills, no banding, and exactly two rules in the whole table, one under the column labels and one closing the body. Everything else is done with space and alignment.

Usage

gt_theme_swiss(
  gt_object,
  accent = "#111111",
  density = c("comfortable", "social", "compact"),
  ...
)

Arguments

gt_object

A gt table object to modify.

accent

Character. A hex color, used once, on the rule beneath the column labels. Defaults to "#111111", which reads as no color at all.

density

Character. The type and padding scale. One of "comfortable", "compact", or "social". See Density. Defaults to "comfortable".

...

Additional arguments passed to gt::tab_options, applied last so they override anything the theme sets.

Value

Returns a modified gt table with the theme applied.

Details

Alignment is strict. Text sits flush left, numbers flush right, and nothing is centered.

Density

density sets the type and padding scale together. "comfortable" uses a 14px body with roomy rows, "compact" a 12px body with tight rows, and "social" a 17px body with generous rows and a larger title, at the scale gt_save_crop() and gt_social_crop() export at.

Figures

Preview of the swiss theme

Examples

library(gt)
afc_west <- subset(
  sdv_example_standings, division == "AFC West",
  c(team_name, wins:points_against)
)
gt(afc_west) |> gt_theme_swiss()
team_name wins losses ties win_pct points_for points_against
Denver Broncos 14 3 0 0.824 401 311
Los Angeles Chargers 11 6 0 0.647 368 340
Kansas City Chiefs 6 11 0 0.353 362 328
Las Vegas Raiders 3 14 0 0.176 241 432
pacific <- subset( sdv_example_standings, division == "Pacific", c(team_name, wins, losses, win_pct:points_against) ) gt(pacific) |> gt_theme_swiss(accent = "#D33A2C")
team_name wins losses win_pct points_for points_against
Los Angeles Lakers 53 29 0.646 9540 9396
Phoenix Suns 45 37 0.549 9232 9112
LA Clippers 42 40 0.512 9329 9236
Golden State Warriors 37 45 0.451 9398 9444
Sacramento Kings 22 60 0.268 9102 9922