Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Border customization (colors & padding) #1921

Open
gitmoneyMSBA opened this issue Nov 13, 2024 · 0 comments
Open

Border customization (colors & padding) #1921

gitmoneyMSBA opened this issue Nov 13, 2024 · 0 comments

Comments

@gitmoneyMSBA
Copy link

There are two features that I'm surprised don't extend to table borders (it's quite possible, and I hope! that I'm using them wrong):

  1. Padding in margins so that a border doesn't take up the whole cell; an extension of opt_horizontal_padding or opt_vertical_padding.
  2. Ability to use color values from another column to color borders within a specific column using the from_column function in the color argument of cell_borders.

For the color-related issue, here is what I attempted and what I recieved:

SUCCESS

exibble %>%
  gt() %>%
  cols_align(align = "center",
             columns = c("char")) %>%
  tab_style(
    style = list(
      cell_borders(
        sides = c("all"),
        color = c("purple"),
        weight = px(3)
      )
    ),
    locations = list(
      cells_body(
        columns = "char",
        rows = char == "fig"
      )
    )
  )

fig

FAILURE

exibble %>%
  mutate(col = case_when(char == "fig" ~ "purple",
                         char == "banana" ~ "yellow",
                         TRUE ~ "white")) %>%
  gt() %>%
  cols_align(align = "center",
             columns = c("char")) %>%
  tab_style(
    style = list(
      cell_borders(
        sides = c("all"),
        color = from_column(col),
        weight = px(3)
      )
    ),
    locations = list(
      cells_body(
        columns = "char",
        rows = !is.na(col)
      )
    )
  )

Meanwhile, re: my first question, how can I get borders that look like the orange ones (instead of the black ones that wrap the whole cell)...?

Rplot_amended

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant