With loc.header(), we can target the table header which contains the title and the subtitle. This is useful for applying custom styling with the tab_style() method. That method has a locations= argument and this class should be used there to perform the targeting.
A LocHeader object, which is used for a locations= argument if specifying the title of the table.
Examples
Let’s use a subset of the gtcars dataset in a new table. We will style the entire table header (the ‘title’ and ‘subtitle’ parts. This can be done by using locations=loc.header() within tab_style().
from great_tables import GT, style, locfrom great_tables.data import gtcars( GT(gtcars[["mfr", "model", "msrp"]].head(5)) .tab_header( title="Select Cars from the gtcars Dataset", subtitle="Only the first five cars are displayed" ) .tab_style( style=style.fill(color="lightblue"), locations=loc.header() ) .fmt_currency(columns="msrp", decimals=0))