The cell_borders() helper function is to be used with the tab_style() function, which itself allows for the setting of custom styles to one or more cells. Specifically, the call to cell_borders() should be bound to the styles argument of tab_style(). The selection argument is where we define which borders should be modified (e.g., "left", "right", etc.). With that selection, the color, style, and weight of the selected borders can then be modified.

cell_borders(sides = "all", color = "#000000", style = "solid", weight = px(1))



The border sides to be modified. Options include "left", "right", "top", and "bottom". For all borders surrounding the selected cells, we can use the "all" option.

color, style, weight

The border color, style, and weight. The color can be defined with a color name or with a hexadecimal color code. The default color value is "#000000" (black). The style can be one of either "solid" (the default), "dashed", or "dotted". The weight of the border lines is to be given in pixel values (the px() helper function is useful for this. The default value for weight is "1px". Borders for any defined sides can be removed by supplying NULL to any of color, style, or weight.


A list object of class cell_styles.


Function ID


See also


# Add horizontal border lines for # all table body rows in `exibble` tab_1 <- exibble %>% gt() %>% tab_options(row.striping.include_table_body = FALSE) %>% tab_style( style = cell_borders( sides = c("top", "bottom"), color = "#BBBBBB", weight = px(1.5), style = "solid" ), locations = cells_body( columns = everything(), rows = everything() ) ) # Incorporate different horizontal and # vertical borders at several locations; # this uses multiple `cell_borders()` and # `cells_body()` calls within `list()`s tab_2 <- exibble %>% gt() %>% tab_style( style = list( cell_borders( sides = c("top", "bottom"), color = "#FF0000", weight = px(2) ), cell_borders( sides = c("left", "right"), color = "#0000FF", weight = px(2) ) ), locations = list( cells_body( columns = vars(num), rows = ), cells_body( columns = vars(currency), rows = ) ) )