tab_options | R Documentation |
Modify the options available in a table. These options are named by the components, the subcomponents, and the element that can adjusted.
tab_options(
data,
table.width = NULL,
table.layout = NULL,
table.align = NULL,
table.margin.left = NULL,
table.margin.right = NULL,
table.background.color = NULL,
table.additional_css = NULL,
table.font.names = NULL,
table.font.size = NULL,
table.font.weight = NULL,
table.font.style = NULL,
table.font.color = NULL,
table.font.color.light = NULL,
table.border.top.style = NULL,
table.border.top.width = NULL,
table.border.top.color = NULL,
table.border.right.style = NULL,
table.border.right.width = NULL,
table.border.right.color = NULL,
table.border.bottom.style = NULL,
table.border.bottom.width = NULL,
table.border.bottom.color = NULL,
table.border.left.style = NULL,
table.border.left.width = NULL,
table.border.left.color = NULL,
heading.background.color = NULL,
heading.align = NULL,
heading.title.font.size = NULL,
heading.title.font.weight = NULL,
heading.subtitle.font.size = NULL,
heading.subtitle.font.weight = NULL,
heading.padding = NULL,
heading.padding.horizontal = NULL,
heading.border.bottom.style = NULL,
heading.border.bottom.width = NULL,
heading.border.bottom.color = NULL,
heading.border.lr.style = NULL,
heading.border.lr.width = NULL,
heading.border.lr.color = NULL,
column_labels.background.color = NULL,
column_labels.font.size = NULL,
column_labels.font.weight = NULL,
column_labels.text_transform = NULL,
column_labels.padding = NULL,
column_labels.padding.horizontal = NULL,
column_labels.vlines.style = NULL,
column_labels.vlines.width = NULL,
column_labels.vlines.color = NULL,
column_labels.border.top.style = NULL,
column_labels.border.top.width = NULL,
column_labels.border.top.color = NULL,
column_labels.border.bottom.style = NULL,
column_labels.border.bottom.width = NULL,
column_labels.border.bottom.color = NULL,
column_labels.border.lr.style = NULL,
column_labels.border.lr.width = NULL,
column_labels.border.lr.color = NULL,
column_labels.hidden = NULL,
column_labels.units_pattern = NULL,
row_group.background.color = NULL,
row_group.font.size = NULL,
row_group.font.weight = NULL,
row_group.text_transform = NULL,
row_group.padding = NULL,
row_group.padding.horizontal = NULL,
row_group.border.top.style = NULL,
row_group.border.top.width = NULL,
row_group.border.top.color = NULL,
row_group.border.bottom.style = NULL,
row_group.border.bottom.width = NULL,
row_group.border.bottom.color = NULL,
row_group.border.left.style = NULL,
row_group.border.left.width = NULL,
row_group.border.left.color = NULL,
row_group.border.right.style = NULL,
row_group.border.right.width = NULL,
row_group.border.right.color = NULL,
row_group.default_label = NULL,
row_group.as_column = NULL,
table_body.hlines.style = NULL,
table_body.hlines.width = NULL,
table_body.hlines.color = NULL,
table_body.vlines.style = NULL,
table_body.vlines.width = NULL,
table_body.vlines.color = NULL,
table_body.border.top.style = NULL,
table_body.border.top.width = NULL,
table_body.border.top.color = NULL,
table_body.border.bottom.style = NULL,
table_body.border.bottom.width = NULL,
table_body.border.bottom.color = NULL,
stub.background.color = NULL,
stub.font.size = NULL,
stub.font.weight = NULL,
stub.text_transform = NULL,
stub.border.style = NULL,
stub.border.width = NULL,
stub.border.color = NULL,
stub.indent_length = NULL,
stub_row_group.font.size = NULL,
stub_row_group.font.weight = NULL,
stub_row_group.text_transform = NULL,
stub_row_group.border.style = NULL,
stub_row_group.border.width = NULL,
stub_row_group.border.color = NULL,
data_row.padding = NULL,
data_row.padding.horizontal = NULL,
summary_row.background.color = NULL,
summary_row.text_transform = NULL,
summary_row.padding = NULL,
summary_row.padding.horizontal = NULL,
summary_row.border.style = NULL,
summary_row.border.width = NULL,
summary_row.border.color = NULL,
grand_summary_row.background.color = NULL,
grand_summary_row.text_transform = NULL,
grand_summary_row.padding = NULL,
grand_summary_row.padding.horizontal = NULL,
grand_summary_row.border.style = NULL,
grand_summary_row.border.width = NULL,
grand_summary_row.border.color = NULL,
footnotes.background.color = NULL,
footnotes.font.size = NULL,
footnotes.padding = NULL,
footnotes.padding.horizontal = NULL,
footnotes.border.bottom.style = NULL,
footnotes.border.bottom.width = NULL,
footnotes.border.bottom.color = NULL,
footnotes.border.lr.style = NULL,
footnotes.border.lr.width = NULL,
footnotes.border.lr.color = NULL,
footnotes.marks = NULL,
footnotes.spec_ref = NULL,
footnotes.spec_ftr = NULL,
footnotes.multiline = NULL,
footnotes.sep = NULL,
source_notes.background.color = NULL,
source_notes.font.size = NULL,
source_notes.padding = NULL,
source_notes.padding.horizontal = NULL,
source_notes.border.bottom.style = NULL,
source_notes.border.bottom.width = NULL,
source_notes.border.bottom.color = NULL,
source_notes.border.lr.style = NULL,
source_notes.border.lr.width = NULL,
source_notes.border.lr.color = NULL,
source_notes.multiline = NULL,
source_notes.sep = NULL,
row.striping.background_color = NULL,
row.striping.include_stub = NULL,
row.striping.include_table_body = NULL,
container.width = NULL,
container.height = NULL,
container.padding.x = NULL,
container.padding.y = NULL,
container.overflow.x = NULL,
container.overflow.y = NULL,
ihtml.active = NULL,
ihtml.use_pagination = NULL,
ihtml.use_pagination_info = NULL,
ihtml.use_sorting = NULL,
ihtml.use_search = NULL,
ihtml.use_filters = NULL,
ihtml.use_resizers = NULL,
ihtml.use_highlight = NULL,
ihtml.use_compact_mode = NULL,
ihtml.use_text_wrapping = NULL,
ihtml.use_page_size_select = NULL,
ihtml.page_size_default = NULL,
ihtml.page_size_values = NULL,
ihtml.pagination_type = NULL,
ihtml.height = NULL,
ihtml.selection_mode = NULL,
page.orientation = NULL,
page.numbering = NULL,
page.header.use_tbl_headings = NULL,
page.footer.use_tbl_notes = NULL,
page.width = NULL,
page.height = NULL,
page.margin.left = NULL,
page.margin.right = NULL,
page.margin.top = NULL,
page.margin.bottom = NULL,
page.header.height = NULL,
page.footer.height = NULL,
quarto.use_bootstrap = NULL,
quarto.disable_processing = NULL,
latex.use_longtable = NULL,
latex.tbl.pos = NULL
)
data |
The gt table data object
This is the gt table object that is commonly created through use of the
|
table.width |
Table width The table width can be specified as a single-length character with units of
pixels or as a percentage. If provided as a single-length numeric vector,
it is assumed that the value is given in units of pixels. The |
table.layout |
The table-layout property This is the value for the |
table.align |
Horizontal alignment of table The |
table.margin.left , table.margin.right |
Left and right table margins The size of the margins on the left and right of the table within the
container can be set with |
table.background.color , heading.background.color , column_labels.background.color , row_group.background.color , stub.background.color , summary_row.background.color , grand_summary_row.background.color , footnotes.background.color , source_notes.background.color |
Background colors These options govern background colors for the parent element |
table.additional_css |
Additional CSS The |
table.font.names |
Default table fonts The names of the fonts used for the table can be supplied through
|
table.font.size , heading.title.font.size , heading.subtitle.font.size , column_labels.font.size , row_group.font.size , stub.font.size , footnotes.font.size , source_notes.font.size |
Table font sizes The font sizes for the parent text element |
table.font.weight , heading.title.font.weight , heading.subtitle.font.weight , column_labels.font.weight , row_group.font.weight , stub.font.weight |
Table font weights The font weights of the table, |
table.font.style |
Default table font style This is the default font style for the table. Can be one of either
|
table.font.color , table.font.color.light |
Default dark and light text for the table These options define text colors used throughout the table. There are two
variants: |
table.border.top.style , table.border.top.width , table.border.top.color , table.border.right.style , table.border.right.width , table.border.right.color , table.border.bottom.style , table.border.bottom.width , table.border.bottom.color , table.border.left.style , table.border.left.width , table.border.left.color |
Top border properties The style, width, and color properties of the table's absolute top and absolute bottom borders. |
heading.align |
Horizontal alignment in the table header Controls the horizontal alignment of the heading title and subtitle. We can
either use |
heading.padding , column_labels.padding , data_row.padding , row_group.padding , summary_row.padding , grand_summary_row.padding , footnotes.padding , source_notes.padding |
Vertical padding throughout the table The amount of vertical padding to incorporate in the |
heading.padding.horizontal , column_labels.padding.horizontal , data_row.padding.horizontal , row_group.padding.horizontal , summary_row.padding.horizontal , grand_summary_row.padding.horizontal , footnotes.padding.horizontal , source_notes.padding.horizontal |
Horizontal padding throughout the table The amount of horizontal padding to incorporate in the |
heading.border.bottom.style , heading.border.bottom.width , heading.border.bottom.color |
Properties of the header's bottom border The style, width, and color properties of the header's bottom border. This
border shares space with that of the |
heading.border.lr.style , heading.border.lr.width , heading.border.lr.color |
Properties of the header's left and right borders The style, width, and color properties for the left and right borders of
the |
column_labels.text_transform , row_group.text_transform , stub.text_transform , summary_row.text_transform , grand_summary_row.text_transform |
Text transforms throughout the table Options to apply text transformations to the |
column_labels.vlines.style , column_labels.vlines.width , column_labels.vlines.color |
Properties of all vertical lines by the column labels The style, width, and color properties for all vertical lines ('vlines')
of the |
column_labels.border.top.style , column_labels.border.top.width , column_labels.border.top.color |
Properties of the border above the column labels The style, width, and color properties for the top border of the
|
column_labels.border.bottom.style , column_labels.border.bottom.width , column_labels.border.bottom.color |
Properties of the border below the column labels The style, width, and color properties for the bottom border of the
|
column_labels.border.lr.style , column_labels.border.lr.width , column_labels.border.lr.color |
Properties of the left and right borders next to the column labels The style, width, and color properties for the left and right borders of
the |
Hiding all column labels An option to hide the column labels. If providing | |
column_labels.units_pattern |
Pattern to combine column labels and units The default pattern for combining column labels with any defined units for
column labels. The pattern is initialized as |
row_group.border.top.style , row_group.border.top.width , row_group.border.top.color , row_group.border.bottom.style , row_group.border.bottom.width , row_group.border.bottom.color , row_group.border.left.style , row_group.border.left.width , row_group.border.left.color , row_group.border.right.style , row_group.border.right.width , row_group.border.right.color |
Border properties associated with the The style, width, and color properties for all top, bottom, left, and right
borders of the |
row_group.default_label |
The default row group label An option to set a default row group label for any rows not formally placed
in a row group named by |
row_group.as_column |
Structure row groups with a column How should row groups be structured? By default, they are separate rows
that lie above the each of the groups. Setting this to |
table_body.hlines.style , table_body.hlines.width , table_body.hlines.color , table_body.vlines.style , table_body.vlines.width , table_body.vlines.color |
Properties of all horizontal and vertical lines in the table body The style, width, and color properties for all horizontal lines ('hlines')
and vertical lines ('vlines') in the |
table_body.border.top.style , table_body.border.top.width , table_body.border.top.color , table_body.border.bottom.style , table_body.border.bottom.width , table_body.border.bottom.color |
Properties of top and bottom borders in the table body The style, width, and color properties for all top and bottom borders of
the |
stub.border.style , stub.border.width , stub.border.color |
Properties of the vertical border of the table stub The style, width, and color properties for the vertical border of the table stub. |
stub.indent_length |
Width of each indentation The width of each indentation level for row labels in the stub. The
indentation can be set by using |
stub_row_group.font.size , stub_row_group.font.weight , stub_row_group.text_transform , stub_row_group.border.style , stub_row_group.border.width , stub_row_group.border.color |
Properties of the row group column in the table stub Options for the row group column in the table stub (made possible when
using |
summary_row.border.style , summary_row.border.width , summary_row.border.color |
Properties of horizontal borders belonging to summary rows The style, width, and color properties for all horizontal borders of the
|
grand_summary_row.border.style , grand_summary_row.border.width , grand_summary_row.border.color |
Properties of horizontal borders belonging to grand summary rows The style, width, and color properties for the top borders of the
|
footnotes.border.bottom.style , footnotes.border.bottom.width , footnotes.border.bottom.color |
Properties of the bottom border belonging to the footnotes The style, width, and color properties for the bottom border of the
|
footnotes.border.lr.style , footnotes.border.lr.width , footnotes.border.lr.color |
Properties of left and right borders belonging to the footnotes The style, width, and color properties for the left and right borders of
the |
footnotes.marks |
Sequence of footnote marks The set of sequential marks used to reference and identify each of the
footnotes (same input as |
footnotes.spec_ref , footnotes.spec_ftr |
Specifications for formatting of footnote marks Optional specifications for formatting of footnote references
( |
footnotes.multiline , source_notes.multiline |
Typesetting of multiple footnotes and source notes An option to either put footnotes and source notes in separate lines (the
default, or |
footnotes.sep , source_notes.sep |
Separator characters between adjacent footnotes and source notes The separating characters between adjacent footnotes and source notes in
their respective footer sections when rendered as a continuous line of text
(when |
source_notes.border.bottom.style , source_notes.border.bottom.width , source_notes.border.bottom.color |
Properties of the bottom border belonging to the source notes The style, width, and color properties for the bottom border of the
|
source_notes.border.lr.style , source_notes.border.lr.width , source_notes.border.lr.color |
Properties of left and right borders belonging to the source notes The style, width, and color properties for the left and right borders of
the |
row.striping.background_color |
Background color for row stripes The background color for striped table body rows. A color name or a hexadecimal color code should be provided. |
row.striping.include_stub |
Inclusion of the table stub for row stripes An option for whether to include the stub when striping rows. |
row.striping.include_table_body |
Inclusion of the table body for row stripes An option for whether to include the table body when striping rows. |
container.width , container.height , container.padding.x , container.padding.y |
Table container dimensions and padding The width and height of the table's container, and, the vertical and
horizontal padding of the table's container. The container width and height
can be specified with units of pixels or as a percentage. The padding is to
be specified as a length with units of pixels. If provided as a numeric
value, it is assumed that the value is given in units of pixels. The |
container.overflow.x , container.overflow.y |
Table container overflow Options to enable scrolling in the horizontal and vertical directions when
the table content overflows the container dimensions. Using |
ihtml.active |
Display interactive HTML table The option for displaying an interactive version of an HTML table (rather
than an otherwise 'static' table). This enables the use of controls for
pagination, global search, filtering, and sorting. The individual features
are controlled by the other |
ihtml.use_pagination , ihtml.use_pagination_info |
Use pagination For interactive HTML output, the option for using pagination controls
(below the table body) can be controlled with |
ihtml.use_sorting |
Provide column sorting controls For interactive HTML output, the option to provide controls for sorting
column values. By default, this is |
ihtml.use_search |
Provide a global search field For interactive HTML output, an option that places a search field for
globally filtering rows to the requested content. By default, this is
|
ihtml.use_filters |
Display filtering fields For interactive HTML output, this places search fields below each column
header and allows for filtering by column. By default, this is |
ihtml.use_resizers |
Allow column resizing For interactive HTML output, this allows for interactive resizing of
columns. By default, this is |
ihtml.use_highlight |
Enable row highlighting on hover For interactive HTML output, this highlights individual rows upon hover. By
default, this is |
ihtml.use_compact_mode |
Use compact mode For interactive HTML output, an option to reduce vertical padding and thus
make the table consume less vertical space. By default, this is |
ihtml.use_text_wrapping |
Use text wrapping For interactive HTML output, an option to control text wrapping. By default
( |
ihtml.use_page_size_select , ihtml.page_size_default , ihtml.page_size_values |
Change page size properties For interactive HTML output, |
ihtml.pagination_type |
Change pagination mode For interactive HTML output and when using pagination, one of three options
for presentation pagination controls. The default is |
ihtml.height |
Height of interactive HTML table Height of the table in pixels. Defaults to |
ihtml.selection_mode |
Allow row selection For interactive HTML output, this allows users to select rows by clicking
them. When this option is |
page.orientation |
Set RTF page orientation For RTF output, this provides two options for page
orientation: |
page.numbering |
Enable RTF page numbering Within RTF output, should page numbering be displayed? By default, this is
set to |
page.header.use_tbl_headings |
Place table headings in RTF page header If |
page.footer.use_tbl_notes |
Place table footer in RTF page footer If |
page.width , page.height |
Set RTF page dimensions The page width and height in the standard portrait orientation. This is for
RTF table output and the default values (in inches) are |
page.margin.left , page.margin.right , page.margin.top , page.margin.bottom |
Set RTF page margins For RTF table output, these options correspond to the left, right, top, and
bottom page margins. The default values for each of these is |
page.header.height , page.footer.height |
Set RTF page header and footer distances The heights of the page header and footer for RTF table outputs. Default
values for both are |
quarto.use_bootstrap , quarto.disable_processing |
Modify Quarto properties When rendering a gt table with Quarto, the table can undergo
transformations to support advanced Quarto features. Setting
|
latex.use_longtable |
Use longtable latex environment By default, tables produced using latex code will be embedded in the
|
latex.tbl.pos |
Specify latex floating position The latex position indicator for a floating environment (e.g., |
An object of class gt_tbl
.
Use select columns from the exibble
dataset to create a gt table with
a number of table parts added (using functions like summary_rows()
,
grand_summary_rows()
, and more). We can use this gt object going
forward to demo some of tab_options()
features.
tab_1 <- exibble |> dplyr::select(-c(fctr, date, time, datetime)) |> gt( rowname_col = "row", groupname_col = "group" ) |> tab_header( title = md("Data listing from **exibble**"), subtitle = md("`exibble` is an R dataset") ) |> fmt_number(columns = num) |> fmt_currency(columns = currency) |> tab_footnote( footnote = "Using commas for separators.", locations = cells_body( columns = num, rows = num > 1000 ) ) |> tab_footnote( footnote = "Using commas for separators.", locations = cells_body( columns = currency, rows = currency > 1000 ) ) |> tab_footnote( footnote = "Alphabetical fruit.", locations = cells_column_labels(columns = char) ) tab_1
We can modify the table width to be set as '100%'. In effect, this spans the
table to entirely fill the content width area. This is done with the
table.width
option and we take advantage of the pct()
helper function.
tab_1 |> tab_options(table.width = pct(100))
With the table.background.color
option, we can modify the table's
background color. Here, we want that to be "lightcyan"
.
tab_1 |> tab_options(table.background.color = "lightcyan")
We have footnotes residing in the footer section of tab_1
. By default, each
footnote takes up a new line of text. This can be changed with the
footnotes.multiline
option. Using FALSE
with that means that all
footnotes will be placed into one continuous span of text. Speaking of
footnotes, we can change the 'marks' used to identify them. Here, we'll use
letters as the marks for footnote references (instead of the default, which
is numbers). This is accomplished with the footnotes.marks
option, and we
are going to supply the letters
vector to that.
tab_1 |> tab_options( footnotes.multiline = FALSE, footnotes.marks = letters )
The data rows of a table typically take up the most physical space but we
have some control over the extent of that. With the data_row.padding
option, it's possible to modify the top and bottom padding of data rows.
We'll do just that in the following example, reducing the padding to a value
of 5 px (note that we are using the px()
helper function here).
tab_1 |> tab_options(data_row.padding = px(5))
The size of the title and the subtitle text in the header of the table can be
altered with the heading.title.font.size
and heading.subtitle.font.size
options. Here, we'll use the "small"
keyword as a value for both options.
tab_1 |> tab_options( heading.title.font.size = "small", heading.subtitle.font.size = "small" )
2-12
v0.2.0.5
(March 31, 2020)
Other part creation/modification functions:
tab_caption()
,
tab_footnote()
,
tab_header()
,
tab_info()
,
tab_row_group()
,
tab_source_note()
,
tab_spanner()
,
tab_spanner_delim()
,
tab_stub_indent()
,
tab_stubhead()
,
tab_style()
,
tab_style_body()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.