posit-dev / great-tables

Make awesome display tables using Python.
https://posit-dev.github.io/great-tables/
MIT License
1.42k stars 48 forks source link

How to style stub? #385

Open dafriedman97 opened 4 days ago

dafriedman97 commented 4 days ago

Is it possible to add styling in the stub? I can style a regular column like this:

from great_tables import GT, md, html, style, loc
from great_tables.data import islands

islands_mini = islands.head(5)
(
    GT(islands_mini)
    .tab_stub(rowname_col="name")
    .tab_style(
        style=style.fill('lightgray'),
        locations=loc.body(columns=['size'])
    )
)
image

But how could I style the stub group (i.e. make the geographical names colored)?

jrycw commented 19 hours ago

@dafriedman97, maybe try using tab_options:

from great_tables import GT, loc, style
from great_tables.data import islands

islands_mini = islands.head(5)
(
    GT(islands_mini)
    .tab_stub(rowname_col="name")
    .tab_style(style=style.fill("lightgray"), locations=loc.body(columns=["size"]))
    .tab_options(stub_background_color="lightgreen")
)

image