from great_tables import px
px(12)'12px'
Helper for providing a CSS length value in pixels.
Usage
For certain parameters, a length value is required. Examples include the setting of font sizes (e.g., in style.text()) and thicknesses of lines (e.g., in style.borders()). Setting a length in pixels with px() allows for an absolute definition of size as opposed to the analogous helper function pct().
x: float"12px") for some arguments that can take values as units of pixels.
str"12px").
The px() helper turns a number into a CSS length in pixels.
Here, px() gives the font size of the num column’s values and the thickness of the line under the char column’s values.
from great_tables import GT, exibble, loc, style
(
GT(exibble[["num", "char"]].head(3))
.tab_style(style=style.text(size=px(18)), locations=loc.body(columns="num"))
.tab_style(
style=style.borders(sides="bottom", color="steelblue", weight=px(3)),
locations=loc.body(columns="char"),
)
)| num | char |
|---|---|
| 0.1111 | apricot |
| 2.222 | banana |
| 33.33 | coconut |