Styling and Options
tab_style!
Apply inline styling to body cells in the specified columns. Colors are hex strings ("#RRGGBB").
Signatures:
tab_style!(tbl, columns::Symbol...; color=nothing, bold=nothing, italic=nothing, underline=nothing)
tab_style!(tbl, columns::AbstractVector{Symbol}; color=nothing, bold=nothing, italic=nothing, underline=nothing)using StyledTables, DataFrames
df = DataFrame(
metric = ["Revenue", "EBITDA", "Net Income"],
q1 = [1.2, 0.3, 0.18],
q2 = [1.4, 0.35, 0.21],
yoy_pct = [0.12, 0.08, 0.14],
)
tbl = StyledTable(df)
tab_header!(tbl, "Q2 2026 Financial Summary")
tab_style!(tbl, :yoy_pct; color = "#1a7340", bold = true)
fmt_percent!(tbl, :yoy_pct; digits = 1)
cols_label!(tbl,
:metric => "Metric",
:q1 => "Q1 (€B)",
:q2 => "Q2 (€B)",
:yoy_pct => "YoY Change",
)
render(tbl)| Q2 2026 Financial Summary | |||
| Metric | Q1 (€B) | Q2 (€B) | YoY Change |
| Revenue | 1.2 | 1.4 | 12.0% |
| EBITDA | 0.3 | 0.35 | 8.0% |
| Net Income | 0.18 | 0.21 | 14.0% |
StyledTables.tab_style! Method
tab_style!(
tbl::StyledTable,
columns::Symbol...;
color,
bold,
italic,
underline
) -> StyledTableApply inline styling to body cells in the listed columns (variadic form).
Returns
tbl (modified in place).
Keywords
color: color value — hex string ("#RRGGBB"), CSS name ("green"), symbol (:green), or aColors.Colorant.nothinginherits the default. Alpha channels are silently dropped.bold:true/false, ornothing.italic:true/false, ornothing.underline:true/false, ornothing.
Examples
tbl = StyledTable(df)
tab_style!(tbl, :pct; color = "#1a7340", bold = true)
render(tbl)StyledTables.tab_style! Method
tab_style!(
tbl::StyledTable,
columns::AbstractVector{Symbol};
color,
bold,
italic,
underline
) -> StyledTableApply inline styling to all body cells in the specified columns.
Any keyword left as nothing is inherited from the cell default.
Arguments
tbl: theStyledTableto modify.columns: column names to style.
Keywords
color: color value — hex string ("#RRGGBB"), CSS name ("green"), symbol (:green), or aColors.Colorant.nothinginherits the default. Alpha channels are silently dropped.bold:true/false, ornothing.italic:true/false, ornothing.underline:true/false, ornothing.
Returns
tbl (modified in place).
See also: fmt!, cols_align!.
Examples
tbl = StyledTable(df)
tab_style!(tbl, [:pct, :n]; color = "#1a7340", bold = true)
render(tbl)Conditional styling
Pass a function as the first argument to style cells based on their raw DataFrame value (before any formatter is applied).
f(raw_value) -> Union{Nothing, NamedTuple} — return nothing for no style override, or a NamedTuple with any subset of color, bold, italic, underline keys. The color key accepts the same types as the color keyword in tab_style!: a hex string ("#RRGGBB"), a CSS name ("green"), a Symbol (:green), or a Colors.Colorant.
Optional keyword arguments set a static per-column baseline. The function result overrides any baseline key that appears in the returned NamedTuple; keys absent from the NamedTuple inherit the baseline.
Signatures:
tab_style!(f, tbl, columns::Symbol...; color=nothing, bold=nothing, italic=nothing, underline=nothing)
tab_style!(f, tbl, columns::AbstractVector{Symbol}; color=nothing, bold=nothing, italic=nothing, underline=nothing)df_cond = DataFrame(
metric = ["Revenue", "EBITDA", "Net Income"],
change = [0.12, -0.03, 0.07],
)
tbl = StyledTable(df_cond)
tab_style!(tbl, :change) do val
val > 0 ? (; color = :green, bold = true) :
val < 0 ? (; color = :red) :
nothing
end
cols_label!(tbl, :metric => "Metric", :change => "YoY Change")
fmt_percent!(tbl, :change; digits = 1)
render(tbl)| Metric | YoY Change |
| Revenue | 12.0% |
| EBITDA | -3.0% |
| Net Income | 7.0% |
A static baseline can be combined with a function override. Here every cell in :change is italic by default, but positive values are also bolded:
tbl = StyledTable(df_cond)
tab_style!(tbl, :change; italic = true) do val
val > 0 ? (; bold = true) : nothing
end
cols_label!(tbl, :metric => "Metric", :change => "YoY Change")
fmt_percent!(tbl, :change; digits = 1)
render(tbl)| Metric | YoY Change |
| Revenue | 12.0% |
| EBITDA | -3.0% |
| Net Income | 7.0% |
StyledTables.tab_style! Method
tab_style!(
f::Function,
tbl::StyledTable,
columns::Symbol...;
color,
bold,
italic,
underline
) -> StyledTableApply conditional inline styling to body cells (variadic / do-block form).
See the vector form for full documentation.
sourceStyledTables.tab_style! Method
tab_style!(
f::Function,
tbl::StyledTable,
columns::AbstractVector{Symbol};
color,
bold,
italic,
underline
) -> StyledTableApply conditional inline styling to body cells in the listed columns.
f(x) -> Union{Nothing, NamedTuple} receives each cell's raw DataFrame value (before any formatter) and returns either nothing (no conditional style) or a NamedTuple with any of color, bold, italic, underline.
Optional kwargs set a per-column baseline. The function result overrides any baseline property whose key is present in the returned NamedTuple.
Setting a key to nothing explicitly clears the static baseline for that property.
Returns
tbl (modified in place).
Keywords
color: baseline color — hex string, CSS name,Symbol, orColors.Colorant.bold:true/false, ornothing.italic:true/false, ornothing.underline:true/false, ornothing.
Examples
tbl = StyledTable(df)
tab_style!(tbl, :change) do val
val > 0 ? (; color=:green, bold=true) :
val < 0 ? (; color=:red) :
nothing
end
render(tbl)sub_missing!
Replace missing values with a placeholder string for display.
Signature: sub_missing!(tbl, r)
df = DataFrame(
group = ["A", "A", "B", "B"],
value = [1.2, missing, 3.4, missing],
)
tbl = StyledTable(df)
sub_missing!(tbl, "–")
render(tbl)| group | value |
| A | 1.2 |
| A | – |
| B | 3.4 |
| B | – |
Any String works as a placeholder:
tbl = StyledTable(df)
sub_missing!(tbl, "N/A")
render(tbl)| group | value |
| A | 1.2 |
| A | N/A |
| B | 3.4 |
| B | N/A |
StyledTables.sub_missing! Function
sub_missing!(tbl::StyledTable, r) -> StyledTableReplace missing values with a display placeholder.
Arguments
tbl: theStyledTableto modify.r: replacement display value
Returns
tbl (modified in place).
See also: fmt!.
Examples
tbl = StyledTable(df)
sub_missing!(tbl)
render(tbl)