| cell_fill | R Documentation |
cell_fill() 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_fill() should be bound to the styles argument of tab_style().
cell_fill(color = "#D3D3D3", alpha = NULL)
color |
Cell fill color
If nothing is provided for |
alpha |
Transparency value
An optional alpha transparency value for the |
A list object of class cell_styles.
Let's use the exibble dataset to create a simple, two-column gt table
(keeping only the num and currency columns). Styles are added with
tab_style() in two separate calls (targeting different body cells with the
cells_body() helper function). With the cell_fill() helper function we
define cells with a "lightblue" background in one instance, and "gray85"
in the other.
exibble |>
dplyr::select(num, currency) |>
gt() |>
fmt_number(decimals = 1) |>
tab_style(
style = cell_fill(color = "lightblue"),
locations = cells_body(
columns = num,
rows = num >= 5000
)
) |>
tab_style(
style = cell_fill(color = "gray85"),
locations = cells_body(
columns = currency,
rows = currency < 100
)
)
8-26
v0.2.0.5 (March 31, 2020)
Other helper functions:
adjust_luminance(),
cell_borders(),
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.