Themes apply a consistent set of borders, background colors, text styles, and alignment rules to a flextable in a single function call. flextable ships with several built-in themes covering everything from minimal academic styles to dark-mode designs.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.
How themes work
Available themes
theme_vanilla() — clean with horizontal rules
External horizontal lines are 2 pts thick; inner horizontal lines are 0.5 pt. Header text is bold. Text columns are left-aligned; numeric columns are right-aligned.
theme_booktabs() — LaTeX booktabs style
Top and bottom lines of the header and body are 2 pts thick; inner header lines are 0.5 pt. No vertical rules. Matches the LaTeX booktabs package aesthetic.
bold_header = TRUE to bold the header row:
theme_box() — full grid
A complete grid with borders on every cell edge, inner and outer. Header is bold; footer is italic.
theme_borderless() — no borders
All borders are removed. Header text is bold. Text columns are left-aligned; numeric columns are right-aligned.
theme_zebra() — alternating row colors
Alternating background colors in the header and body. Default colors are #CFCFCF for odd header rows and #EFEFEF for odd body rows; even rows are transparent.
theme_alafoli() — minimal with gray text
No background color. All text is #666666. No bold or italic. A single horizontal rule below the header. Compact 3 pt padding.
theme_apa() — APA style
APA (American Psychological Association) style: Times New Roman font, double line spacing, horizontal rules at top, below the header, and at the bottom of the body, centered alignment, and numbers formatted to 2 decimal places.
theme_tron() and theme_tron_legacy() — dark themes
Both use a dark background. Header text is orange/amber; body text is cyan/yellow. All borders are teal/blue.
- theme_tron
- theme_tron_legacy
| Theme | Background | Header color | Body color | Border color |
|---|---|---|---|---|
theme_tron | #000000 | #ec9346 | #a4cee5 | #a4cee5 |
theme_tron_legacy | #0C141F | #DF740C | #FFE64D | #6FC3DF |
theme_vader() — dark with red accents
Dark #242424 background, light #dfdfdf text. A thick red (#ff0000) horizontal rule separates the header from the body.
Setting a default theme
Useset_flextable_defaults() to apply a theme automatically to every new flextable created in the session:
theme_fun is called as the last instruction inside flextable(). This means headers and footers added after the flextable() call are not formatted by the default theme.
To apply a theme after headers and footers have been added, use the post_process_html (or post_process_docx, post_process_pptx, post_process_pdf) argument instead:
flextable().
Be careful that post-process themes do not override formatting you applied explicitly before printing.
Theme summary
| Theme | Borders | Background | Header style |
|---|---|---|---|
theme_vanilla | Horizontal only | None | Bold |
theme_booktabs | Top / mid / bottom | None | Optional bold |
theme_box | Full grid | None | Bold |
theme_borderless | None | None | Bold |
theme_zebra | None | Alternating | Bold |
theme_alafoli | Header bottom only | None | Gray text |
theme_apa | Top, header bottom, body bottom | None | Centered |
theme_tron | Full grid (teal) | Black | Orange, bold |
theme_tron_legacy | Full grid (teal) | Dark navy | Amber, bold |
theme_vader | Red accent lines | Dark gray | Bold |