Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/davidgohel/flextable/llms.txt

Use this file to discover all available pages before exploring further.

Theme functions apply a complete visual style to a flextable in one call. Unlike ggplot2 themes, flextable themes are applied immediately to the existing table structure. Rows or columns added after the theme call are not formatted by the theme.
Apply the theme after all header, footer, and body rows have been added. To apply a theme automatically at print time (so it captures all rows), use set_flextable_defaults(post_process_html = theme_fun, ...) instead.

theme_vanilla()

External horizontal lines are black and 2 pt thick. Internal horizontal lines are 0.5 pt. Header text is bold. Text columns are left-aligned; numeric columns are right-aligned.
theme_vanilla(x)

Example

ft <- flextable(head(airquality))
ft <- theme_vanilla(ft)
ft

theme_booktabs()

Publication-style theme based on the LaTeX booktabs package. Thick borders at the top and bottom of the header and at the bottom of the body. An optional thin line separates header rows.
theme_booktabs(x, bold_header = FALSE, ...)
x
flextable
required
A flextable object.
bold_header
logical
default:"FALSE"
If TRUE, header text is rendered in bold.

Example

ft <- flextable(head(airquality))
ft <- theme_booktabs(ft)
ft

theme_box()

All cells have outer and inner borders. Header text is bold; footer text is italic. Text columns are left-aligned; numeric columns are right-aligned.
theme_box(x)

Example

ft <- flextable(head(airquality))
ft <- theme_box(ft)
ft

theme_borderless()

All borders are removed. Header text is bold. Text columns are left-aligned; numeric columns are right-aligned.
theme_borderless(x)

Example

ft <- flextable(head(airquality))
ft <- theme_borderless(ft)
ft

theme_zebra()

Alternating row background colors in the header and body.
theme_zebra(
  x,
  odd_header  = "#CFCFCF",
  odd_body    = "#EFEFEF",
  even_header = "transparent",
  even_body   = "transparent"
)
x
flextable
required
A flextable object.
odd_header
string
default:"#CFCFCF"
Background color for odd header rows.
odd_body
string
default:"#EFEFEF"
Background color for odd body rows.
even_header
string
default:"transparent"
Background color for even header rows.
even_body
string
default:"transparent"
Background color for even body rows.

Example

ft <- flextable(head(airquality))
ft <- theme_zebra(ft)
ft

theme_alafoli()

Minimalist theme with transparent backgrounds, gray text, and only a bottom border under the header.
theme_alafoli(x)

Example

ft <- flextable(head(airquality))
ft <- theme_alafoli(ft)
ft

theme_apa()

Style conforming to the American Psychological Association (APA) publication guidelines. Uses Times New Roman, double line spacing, centered alignment, and horizontal rules at the top, bottom of the header, and bottom of the body.
theme_apa(x, ...)

Example

ft <- flextable(head(mtcars * 22.22))
ft <- theme_apa(ft)
ft

theme_tron()

Dark background (#000000) with blue borders (#a4cee5), orange header text (#ec9346), and blue body text (#a4cee5). Header text is bold.
theme_tron(x)

Example

ft <- flextable(head(airquality))
ft <- theme_tron(ft)
ft

theme_tron_legacy()

Variant of theme_tron() with a dark navy background (#0C141F), cyan borders (#6FC3DF), orange header text (#DF740C), and yellow body text (#FFE64D).
theme_tron_legacy(x)

Example

ft <- flextable(head(airquality))
ft <- theme_tron_legacy(ft)
ft

theme_vader()

Dark background (#242424) with red borders, light gray text (#dfdfdf), and bold header text. Named after Darth Vader.
theme_vader(x, ...)

Example

ft <- flextable(head(airquality))
ft <- theme_vader(ft)
ft

Parameters common to all themes

x
flextable
required
A flextable object. The function stops with an error if x is not a flextable.

Return value

All theme functions return the modified flextable object.

See also

Build docs developers (and LLMs) love