cell_borders | R Documentation |
cell_borders()
is to be used with tab_style()
, 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 sides
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))
sides |
Border sides
The border sides to be modified. Options include |
color |
Border color
The border |
style |
Border line style
The border |
weight |
Border weight
The default value for |
A list object of class cell_styles
.
We can add horizontal border lines for all table body rows in a gt table
based on the exibble
dataset. For this, we need to use tab_style()
(targeting all cells in the table body with cells_body()
) in conjunction
with cell_borders()
in the style
argument. Both top and bottom borders
will be added as "solid"
and "red"
lines with a line width of 1.5 px.
exibble |> gt() |> tab_style( style = cell_borders( sides = c("top", "bottom"), color = "red", weight = px(1.5), style = "solid" ), locations = cells_body() )
It's possible to incorporate different horizontal and vertical ("left"
and
"right"
) borders at several different locations. This uses multiple
cell_borders()
and cells_body()
calls within their own respective lists.
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 = num, rows = is.na(num) ), cells_body( columns = currency, rows = is.na(currency) ) ) )
8-27
v0.2.0.5
(March 31, 2020)
Other helper functions:
adjust_luminance()
,
cell_fill()
,
cell_text()
,
currency()
,
default_fonts()
,
escape_latex()
,
from_column()
,
google_font()
,
gt_latex_dependencies()
,
html()
,
md()
,
nanoplot_options()
,
pct()
,
px()
,
random_id()
,
row_group()
,
stub()
,
system_fonts()
,
unit_conversion()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.