Skip to contents

Modeled on KenPom's tables. Helvetica Neue type, blue zebra-striped rows, blue column labels and row-group bands set over a light-blue fill, and underlined spanners. The heading is centered.

Usage

gt_theme_kenpom(
  gt_object,
  density = c("comfortable", "compact", "social"),
  ...
)

Arguments

gt_object

A gt table object to modify.

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

The striping is applied by row position, a pale blue (#F2FAFD) on odd rows and a slightly deeper blue (#e5ecf9) on even rows, so it follows the order the data is in. A thin black bottom border separates every body row except the last. To force the spanner row to render so it can be underlined, the theme adds a placeholder spanner and then hides it with display: none in the gt::opt_css() block. A table id is resolved (or generated) up front so that CSS binds to this table alone. density rescales the finished table, since this theme sets its sizes directly rather than deriving them from a scale.

Density

density scales the theme's type and row padding together. "comfortable" leaves every size as the theme sets it, "compact" scales both down, and "social" scales both up, to the scale gt_save_crop() and gt_social_crop() export at.

Figures

Preview of the KenPom theme

Examples

library(gt)
central <- subset(
  sdv_example_standings, division == "Central",
  c(team_name, wins, losses, win_pct:points_against)
)
gt(central) |> gt_theme_kenpom()
team_name wins losses win_pct points_for points_against
Detroit Pistons 60 22 0.732 9657 8988
Cleveland Cavaliers 52 30 0.634 9801 9464
Milwaukee Bucks 32 50 0.390 9072 9581
Chicago Bulls 31 51 0.378 9537 9964
Indiana Pacers 19 63 0.232 9219 9874
gt(central) |> gt_theme_kenpom(density = "compact")
team_name wins losses win_pct points_for points_against
Detroit Pistons 60 22 0.732 9657 8988
Cleveland Cavaliers 52 30 0.634 9801 9464
Milwaukee Bucks 32 50 0.390 9072 9581
Chicago Bulls 31 51 0.378 9537 9964
Indiana Pacers 19 63 0.232 9219 9874