add_title: Add a title above a reactable table

View source: R/table_elements.R

add_titleR Documentation

Add a title above a reactable table

Description

Use 'add_title()' to place a title above a reactable or reactablefmtr table. The title can be aligned to the left, right, or center with the align option. The text properties of the title, such as the font size and font style can be customized. The background color of the title can also be adjusted as well as the margin around the title.

Usage

add_title(
  table = NULL,
  title = NULL,
  align = "left",
  font_color = "#000",
  font_size = 32,
  font_style = "normal",
  font_weight = "bold",
  text_decoration = NULL,
  text_transform = NULL,
  letter_spacing = NULL,
  word_spacing = NULL,
  text_shadow = NULL,
  background_color = "#FFFFFF",
  margin = NULL
)

Arguments

table

A reactable table.

title

A string to be displayed as the title.

align

The alignment of the table. Options are "left", "right", "center". Default is "left".

font_color

Color of the title text. Default is #000.

font_size

Numeric value representing the size of the font of the title (in px). Default is 32.

font_style

Style of the title font. Options are "normal" or "italic". Default is "normal".

font_weight

The font weight of the title. Options are "bold" or "normal". Default is "bold".

text_decoration

Add an underline, overline, or line-through title. Default is NULL.

text_transform

Specify how to capitalize the title. Options are "uppercase", "lowercase", or "capitalize". Default is NULL.

letter_spacing

Numeric value that adjusts the horizontal spacing between letters. A number above 0 adds more spacing between letters, a number below 0 decreases the spacing. Default is NULL.

word_spacing

Numeric value that adjusts the horizontal spacing between words. A number above 0 adds more spacing between words, a number below 0 decreases the spacing. Default is NULL.

text_shadow

Apply a shadow around the title. See <https://developer.mozilla.org/en-US/docs/Web/CSS/text-shadow> for options. Default is NULL.

background_color

Color of the title background. Default is #FFFFFF.

margin

Use margin() to set the margin around the text (top, right, bottom, left). Default is NULL.

Value

a function that adds a title above a reactable table.

Examples

## Not run: 
## Create the reactable table and then pipe in the title
table <- reactable(iris[10:29, ])

table %>%
  add_title("This is a title")

## Use options to adjust the style and position of the title
table %>%
  add_title("This is a title", align = "center", font_color = "red")

## End(Not run)

reactablefmtr documentation built on March 18, 2022, 5:08 p.m.