With loc.title(), we can target the part of table containing the title (within the table header). 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 LocTitle 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 only the ‘title’ part of the table header (leaving the ‘subtitle’ part unaffected). This can be done by using locations=loc.title() 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.text(color="blue", size="large", weight="bold"), locations=loc.title() ) .fmt_currency(columns="msrp", decimals=0))