Wraps a column label onto several short lines so a wide heading stops forcing a narrow column wider than its data needs. "Strength of Schedule" over a two-digit column becomes three stacked lines instead of one long one.
Usage
gt_wrap_labels(
gt_object,
columns = gt::everything(),
width = 12,
balance = TRUE
)Arguments
- gt_object
A
gttable object to modify.- columns
The columns whose labels should wrap. Defaults to
gt::everything().- width
Integer. The target line length in characters. Defaults to
12.- balance
Logical. Should the lines be evened out rather than filled greedily left to right? Defaults to
TRUE.
Details
The hand-rolled version is gt::cols_label(x = gt::html("A<br>B")), written
out per column. This wraps at a width for you, and by default balances the
lines so they come out close to even rather than a long first line over a
short last one.
A label of one word, or one already shorter than width, is left alone. The
wrap is on whitespace only, so a single long word is never split.
