cell_text | R Documentation |
This helper function can be used with tab_style()
, which itself allows for
the setting of custom styles to one or more cells. We can also define several
styles within a single call of cell_text()
and tab_style()
will reliably
apply those styles to the targeted element.
cell_text(
color = NULL,
font = NULL,
size = NULL,
align = NULL,
v_align = NULL,
style = NULL,
weight = NULL,
stretch = NULL,
decorate = NULL,
transform = NULL,
whitespace = NULL,
indent = NULL
)
color |
Text color
The text color can be modified through the |
font |
Font (or collection of fonts) used for text
The font or collection of fonts (subsequent font names are) used as fallbacks. |
size |
Text size
The size of the font. Can be provided as a number that is assumed to
represent |
align |
Text alignment
The text in a cell can be horizontally aligned though one of the following
options: |
v_align |
Vertical alignment
The vertical alignment of the text in the cell can be modified through the
options |
style |
Text style
Can be one of either |
weight |
Font weight
The weight of the font can be modified thorough a text-based option such as
|
stretch |
Stretch text
Allows for text to either be condensed or expanded. We can use one of the
following text-based keywords to describe the degree of
condensation/expansion: |
decorate |
Decorate text
Allows for text decoration effect to be applied. Here, we can use
|
transform |
Transform text
Allows for the transformation of text. Options are |
whitespace |
White-space options
A white-space preservation option. By default, runs of white-space will be
collapsed into single spaces but several options exist to govern how
white-space is collapsed and how lines might wrap at soft-wrap
opportunities. The options are |
indent |
Text indentation
The indentation of the text. Can be provided as a number that is assumed to
represent |
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). With tab_style()
(called twice), we'll selectively add style to the values formatted with
fmt_number()
. We do this by using cell_text()
in the style
argument of
tab_style()
.
exibble |> dplyr::select(num, currency) |> gt() |> fmt_number(decimals = 1) |> tab_style( style = cell_text(weight = "bold"), locations = cells_body( columns = num, rows = num >= 5000 ) ) |> tab_style( style = cell_text(style = "italic"), locations = cells_body( columns = currency, rows = currency < 100 ) )
8-25
v0.2.0.5
(March 31, 2020)
Other helper functions:
adjust_luminance()
,
cell_borders()
,
cell_fill()
,
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.