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

Table borders don't change colors until width = 3 #600

Open
acircleda opened this issue Jun 3, 2020 · 2 comments
Open

Table borders don't change colors until width = 3 #600

acircleda opened this issue Jun 3, 2020 · 2 comments
Milestone

Comments

@acircleda
Copy link

acircleda commented Jun 3, 2020

As I was working on APA styling using gt, I had a difficult time changing the top (first) and bottom (last) table borders. They don't change colors until you set the width to three or more. This is also the same with heading borders and likely other borders set in tab_options. Example:

This does not work:

iris %>%
  slice(1:10) %>%
  gt() %>%
  tab_options(
    table.border.top.width = 2,
    table.border.top.color = "red",
    table.border.bottom.width = 2,
    table.border.bottom.color = "red"
  )

This works:

iris %>%
  slice(1:10) %>%
  gt() %>%
  tab_options(
    table.border.top.width = 3,
    table.border.top.color = "red",
    table.border.bottom.width = 3,
    table.border.bottom.color = "red"
  )
@jthomasmock
Copy link
Collaborator

I was going to open this as an issue, but will instead just drop another reprex!

I can confirm that this behavior is present in gt v 0.2.1.

library(gt)

small_car <- mtcars[1:5,1:5] 

# basic gt table
car_tab <- small_car %>%
  gt()

# Gray top and bottom line on table
car_tab

# Still gray top and bottom line on table
car_tab %>% 
  tab_options(table.border.top.color = "white",
              table_body.hlines.color = "white")

# Still gray top and bottom line on table
car_tab %>% 
  tab_options(table.border.top.color = "white",
              table.border.top.width = 2,
              table.border.bottom.color = "white",
              table.border.bottom.width = 2)

# No top/bottom line (table.border.top.width >= 3)
car_tab %>% 
  tab_options(table.border.top.color = "white",
              table.border.top.width = 3,
              table.border.bottom.color = "white",
              table.border.bottom.width = 3)

@rich-iannone rich-iannone added this to the FUTURE milestone Aug 22, 2022
@rich-iannone rich-iannone changed the title Table borders don't change colors until width = 3 Table borders don't change colors until width = 3 Aug 24, 2022
@a-drumm
Copy link

a-drumm commented Oct 25, 2022

I've run into this same issue and after learning how CSS handles collapsed borders have been able to mostly get around it. If anyone stumbles upon this post trying to figure this out:

For the top border:

  • If you don't have a header, use column_labels.border.top options.
  • If you do have a header, table.border.top options should work fine.

For the bottom border:

  • If you have any footnotes source notes, table.border.bottom options should work.

For tables with no footnotes/source notes:

  • If you don't have any summary rows, use table_body.border.bottom options.
  • If you have summary rows and all you want is 2px solid color border, set table.border.bottom.style = "double" in addition to your chosen table.border.bottom.color. At 2px it'll be solid (sometimes).
  • If you have summary rows and you want less than 2px or a different style there's some css options you can mess with but nothing is 100% so it's probably best to just go with the solid 2px border color of your choosing.

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

No branches or pull requests

4 participants