Theme functions for customizing forest plot appearance.

Custom Theme Creation

web_theme

Create a custom theme by extending a base theme with overrides. This is the most flexible way to create themes when preset themes don’t match your needs.

web_theme(
  name = "custom",
  colors = NULL,
  typography = NULL,
  spacing = NULL,
  shapes = NULL,
  axis = NULL,
  layout = NULL,
  group_headers = NULL,
  base_theme = web_theme_default()
)
Argument Description
name Name for the custom theme
colors Named list of color overrides (see set_colors() for available properties)
typography Named list of typography overrides (see set_typography())
spacing Named list of spacing overrides (see set_spacing())
shapes Named list of shape overrides (see set_shapes())
axis Named list of axis overrides (see set_axis())
layout Named list of layout overrides (see set_layout())
group_headers Named list of group header style overrides (see set_group_headers())
base_theme Base theme to extend (default: web_theme_default())

Example:

my_theme <- web_theme(
  name = "my_journal",
  colors = list(
    primary = "#1a365d",
    interval = "#1a365d",
    interval_line = "#2d3748"
  ),
  typography = list(
    font_family = "Georgia, serif",
    font_size_base = "0.8rem"
  ),
  spacing = list(
    row_height = 22
  ),
  base_theme = web_theme_minimal()
)

Theme Modifiers

All modifiers return the modified theme and can be chained with pipes. These are equivalent to setting the same parameters directly in tabviz().

TipEquivalence with tabviz()

Theme modifier functions and direct tabviz() arguments are equivalent:

# These produce the same result:
tabviz(data, ..., row_height = 32)
tabviz(data, ...) |> set_spacing(row_height = 32)

set_theme

Set or change theme on a WebSpec or widget. Accepts theme name or object.

set_theme(x, theme)
Argument Description
x WebSpec object or htmlwidget
theme Theme name string or WebTheme object

Available theme names: "default", "minimal", "dark", "jama", "lancet", "modern", "presentation", "cochrane", "nature"

Examples:

# Using theme name
tabviz(data, ...) |> set_theme("jama")

# Using theme object
tabviz(data, ...) |> set_theme(web_theme_lancet())

set_colors

Customize theme colors.

set_colors(
  theme,
  background = NULL,
  foreground = NULL,
  primary = NULL,
  secondary = NULL,
  accent = NULL,
  muted = NULL,
  border = NULL,
  interval = NULL,
  interval_positive = NULL,
  interval_negative = NULL,
  interval_neutral = NULL,
  interval_line = NULL,
  summary_fill = NULL,
  summary_border = NULL
)
Argument Default Description Used For
background "#ffffff" Background color Plot container, table cells
foreground "#333333" Primary text color Labels, data values, headers; row_emphasis text
primary "#0891b2" Primary accent color Row group backgrounds, hover states, selection
secondary "#64748b" Secondary text/UI color Subtitles, less prominent UI text
accent "#8b5cf6" Accent color row_accent text styling, annotation labels
muted "#94a3b8" Muted text color Footnotes, captions; row_muted text styling
border "#e2e8f0" Border color Row dividers, container borders
interval "#0891b2" Default marker/interval color CI marker fill (squares, circles)
interval_positive (deprecated) Color for favorable effects
interval_negative (deprecated) Color for unfavorable effects
interval_neutral "#64748b" Color for neutral effects
interval_line "#475569" Confidence interval line color CI whisker lines
summary_fill "#0891b2" Summary diamond fill color Summary row diamonds
summary_border "#0e7490" Summary diamond border color Summary diamond outline

set_typography

Customize fonts and text styling.

set_typography(
  theme,
  font_family = NULL,
  font_size_sm = NULL,
  font_size_base = NULL,
  font_size_lg = NULL,
  font_weight_normal = NULL,
  font_weight_medium = NULL,
  font_weight_bold = NULL,
  line_height = NULL,
  header_font_scale = NULL
)
Argument Default Description
font_family "system-ui, ..." CSS font-family string
font_size_sm "0.75rem" Small text size
font_size_base "0.875rem" Base text size
font_size_lg "1rem" Large text size
font_weight_normal 400 Normal font weight
font_weight_medium 500 Medium font weight
font_weight_bold 600 Bold font weight
line_height 1.5 Line height multiplier
header_font_scale 1.05 Scale factor for header cell font size relative to base

set_spacing

Customize spacing and sizing.

set_spacing(
  theme,
  row_height = NULL,
  header_height = NULL,
  section_gap = NULL,
  padding = NULL,
  container_padding = NULL,
  axis_gap = NULL,
  group_padding = NULL,
  cell_padding_x = NULL,
  cell_padding_y = NULL
)
Argument Default Description
row_height 28 Data row height in pixels
header_height 36 Header row height in pixels
section_gap 16 Gap between sections in pixels
padding 12 Padding around forest plot SVG
container_padding 0 Left/right padding for outer container
axis_gap 12 Gap between table and x-axis
group_padding 8 Column group header padding
cell_padding_x 10 Horizontal cell padding
cell_padding_y 4 Vertical cell padding

set_shapes

Customize shapes and visual elements.

set_shapes(
  theme,
  point_size = NULL,
  summary_height = NULL,
  line_width = NULL,
  border_radius = NULL,
  effect_colors = NULL,
  marker_shapes = NULL
)
Argument Default Description
point_size 6 Point marker radius in pixels
summary_height 10 Summary diamond height in pixels
line_width 1.5 Confidence interval line width
border_radius 2 Border radius for containers
effect_colors NULL Vector of colors for multi-effect visualizations (forest, bar, boxplot, violin)
marker_shapes c("square", ...) Vector of shapes for multi-effect forest plots

set_effect_colors

Set default colors for multi-effect visualizations (forest plots, bar charts, boxplots, violin plots).

set_effect_colors(theme, colors)
Argument Description
theme WebTheme object
colors Character vector of CSS colors

Example:

web_theme_default() |>
  set_effect_colors(c("#2563eb", "#dc2626", "#16a34a"))

set_marker_shapes

Set default marker shapes for multi-effect plots.

set_marker_shapes(theme, shapes)
Argument Description
theme WebTheme object
shapes Character vector: "square", "circle", "diamond", "triangle"

Example:

web_theme_default() |>
  set_marker_shapes(c("square", "circle", "diamond"))

set_axis

Customize axis appearance and auto-scaling behavior.

set_axis(
  theme,
  range_min = NULL,
  range_max = NULL,
  tick_count = NULL,
  tick_values = NULL,
  gridlines = NULL,
  gridline_style = NULL,
  padding = NULL,
  ci_truncation_threshold = NULL,
  include_null = NULL,
  symmetric = NULL,
  null_tick = NULL,
  marker_margin = NULL
)
Argument Default Description
range_min NA Minimum axis value (NA = auto)
range_max NA Maximum axis value (NA = auto)
tick_count NA Target number of ticks (NA = auto)
tick_values NULL Explicit tick positions (numeric vector)
gridlines FALSE Show vertical gridlines
gridline_style "dotted" "solid", "dashed", or "dotted"
padding 0.10 Fraction of range to add as padding (0-1)
ci_truncation_threshold 2.0 Truncate CIs beyond this multiple of estimate range
include_null TRUE Always include null value in axis range
symmetric NULL Make axis symmetric around null (NULL = auto)
null_tick TRUE Always show tick at null value
marker_margin TRUE Add padding at edges to prevent marker clipping

set_layout

Customize layout options.

set_layout(
  theme,
  plot_position = NULL,
  table_width = NULL,
  plot_width = NULL,
  row_border = NULL,
  row_border_style = NULL,
  container_border = NULL,
  container_border_radius = NULL
)
Argument Default Description
plot_position "right" "left" or "right"
table_width "auto" Table width ("auto" or pixels)
plot_width "auto" Plot width ("auto" or pixels)
row_border TRUE Show row borders
row_border_style "solid" "solid", "dashed", "dotted"
container_border FALSE Show container border
container_border_radius 8 Container border radius in pixels

set_group_headers

Customize hierarchical styling for nested row groups (h1/h2/h3-style visual hierarchy).

set_group_headers(
  theme,
  level1_font_size = NULL,
  level1_font_weight = NULL,
  level1_italic = NULL,
  level1_background = NULL,
  level1_border_bottom = NULL,
  level2_font_size = NULL,
  level2_font_weight = NULL,
  level2_italic = NULL,
  level2_background = NULL,
  level2_border_bottom = NULL,
  level3_font_size = NULL,
  level3_font_weight = NULL,
  level3_italic = NULL,
  level3_background = NULL,
  level3_border_bottom = NULL,
  indent_per_level = NULL
)
Argument Default Description
level1_font_size "0.9375rem" Font size for top-level groups
level1_font_weight 600 Font weight for top-level groups
level1_italic FALSE Use italic text for level 1
level1_background NULL Background color (NULL = 15% primary opacity)
level1_border_bottom FALSE Show bottom border on level 1
level2_font_size "0.875rem" Font size for second-level groups
level2_font_weight 500 Font weight for second-level groups
level2_italic FALSE Use italic text for level 2
level2_background NULL Background color (NULL = 10% primary opacity)
level2_border_bottom FALSE Show bottom border on level 2
level3_font_size "0.875rem" Font size for third-level groups
level3_font_weight 400 Font weight for third-level groups
level3_italic FALSE Use italic text for level 3+
level3_background NULL Background color (NULL = 6% primary opacity)
level3_border_bottom FALSE Show bottom border on level 3+
indent_per_level 16 Indentation per nesting level (px)

Example:

web_theme_default() |>
  set_group_headers(
    level1_font_weight = 800,
    level2_italic = FALSE,  # Disable default italic on level 2
    level1_background = "#f0f9ff",
    indent_per_level = 24
  )

Examples

Chaining Modifiers

Code
web_theme_jama() |>
  set_colors(primary = "#0066cc") |>
  set_typography(font_family = "Georgia, serif") |>
  set_spacing(row_height = 28) |>
  set_axis(gridlines = TRUE)

Custom Theme for Publication

Code
publication_theme <- web_theme_minimal() |>
  set_colors(
    foreground = "#1a1a1a",
    interval = "#333333",
    interval_line = "#333333"
  ) |>
  set_typography(
    font_family = "Times New Roman, serif",
    font_size_base = "11pt"
  ) |>
  set_spacing(row_height = 24) |>
  set_axis(gridlines = FALSE)

Customizing Group Header Hierarchy

Code
# Create distinct visual levels for nested groups
web_theme_default() |>
  set_group_headers(
    level1_font_size = "1.1rem",
    level1_font_weight = 800,
    level1_background = "#e0f2fe",  # Light blue
    level2_font_size = "0.95rem",
    level2_font_weight = 500,
    level2_italic = TRUE,           # Italic for level 2 (default)
    level2_background = "#f0f9ff",  # Lighter blue
    level3_font_size = "0.875rem",
    level3_font_weight = 400,
    level3_background = "#fafafa"   # Near white
  )

Preset Themes

web_theme_default

Clean, modern default theme with subtle cyan accents, system fonts, and rounded corners.

web_theme_default()

web_theme_jama

JAMA journal style: maximum density, pure black & white, Arial font, compact rows (18px). Optimized for print.

web_theme_jama()

web_theme_lancet

Elegant academic theme with Lancet navy blue (#00407A), warm off-white background, gold accents, and serif typography (Georgia). Generous spacing with sharp corners.

web_theme_lancet()

web_theme_modern

Bold, vibrant design with Inter font, bright blue (#3B82F6) accents, larger elements (36px rows), and prominent rounded corners (12px). Ideal for digital reports and dashboards.

web_theme_modern()

web_theme_presentation

Oversized theme for slides and posters: extra large fonts (1-1.25rem), thick lines (2.5px), oversized markers (12px), and tall rows (44px). High visibility at distance.

web_theme_presentation()

web_theme_dark

Catppuccin Mocha-inspired dark mode with comfortable low-contrast colors for extended viewing. Blue accents on dark background, soft rounded corners.

web_theme_dark()

web_theme_minimal

Academic publication-ready with pure black & white styling, Georgia serif font, sharp corners. Classic, authoritative look for journal submissions.

web_theme_minimal()

web_theme_cochrane

Cochrane systematic review style: teal accents (#0099CC), Arial font, very compact layout (20px rows). Clean, utilitarian design without decorative elements.

web_theme_cochrane()

web_theme_nature

Nature journal family styling: Nature blue (#1976D2), Helvetica Neue font, tight typography, and precise aesthetic. Balanced between academic rigor and modern readability.

web_theme_nature()

See Also