Skip to content

Conversation

@rich-iannone
Copy link
Member

This PR adds two arguments to tab_options(): column_labels.padding and heading.padding. Several options already exist for easily changing the vertical padding of certain locations, so, these additions make it possible to fully alter to the padding from top to bottom (without resorting to CSS).

Here's some examples of different padding levels applied to the same table (where the padding is 0, 5, and 10px):

library(gt)

padding_px <- x

mtcars[1:5, ] %>%
  gt(rownames_to_stub = TRUE) %>% 
  tab_header(title = "The mtcars Dataset", subtitle = "What a great dataset this is") %>% 
  tab_spanner(label = "performance", columns = c(disp, hp, drat)) %>%
  tab_footnote(footnote = "A table footnote", locations = cells_title("title")) %>%
  tab_source_note(source_note = "Dataset is generally available in R") %>%
  tab_options(
    data_row.padding = px(padding_px),
    column_labels.padding = px(padding_px),
    heading.padding = px(padding_px),
    footnotes.padding = px(padding_px),
    source_notes.padding = px(padding_px)
  )

padding_0

padding_5

padding_10

Here's the table without the tab_options() call (default padding):

default_padding

Fixes: #770

@rich-iannone rich-iannone marked this pull request as ready for review June 14, 2021 13:03
@rich-iannone rich-iannone merged commit 1dd9356 into master Jun 15, 2021
@rich-iannone rich-iannone deleted the tab-options-padding branch June 15, 2021 20:30
rich-iannone added a commit that referenced this pull request Jun 15, 2021
* master:
  Add padding options for heading and column labels (#795)
rich-iannone added a commit that referenced this pull request Jun 16, 2021
* master:
  Add padding options for heading and column labels (#795)
rich-iannone added a commit that referenced this pull request Jun 17, 2021
* master:
  Add padding options for heading and column labels (#795)
rich-iannone added a commit that referenced this pull request Jun 21, 2021
* master:
  Add padding options for heading and column labels (#795)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inability to control cell padding within Table Header and Column Labels

3 participants