great_tables
  • Get Started
  • Examples
  • Reference
  • Blog

On this page

  • style.text
    • Parameters
    • Returns
    • Examples

style.text

style.text(
    color=None,
    font=None,
    size=None,
    align=None,
    v_align=None,
    style=None,
    weight=None,
    stretch=None,
    decorate=None,
    transform=None,
    whitespace=None,
)

A style specification for cell text.

The style.text() class is to be used with the tab_style() method, which itself allows for the setting of custom styles to one or more cells. With it, you can specify the color of the text, the font family, the font size, and the horizontal and vertical alignment of the text and more.

Parameters

color : str | ColumnExpr | None = None

The text color can be modified through the color argument.

font : str | ColumnExpr | GoogleFont | None = None

The font or collection of fonts (subsequent font names are) used as fallbacks.

size : str | ColumnExpr | None = None

The size of the font. Can be provided as a number that is assumed to represent px values (or could be wrapped in the px() helper function). We can also use one of the following absolute size keywords: "xx-small", "x-small", "small", "medium", "large", "x-large", or "xx-large".

align : Literal['center', 'left', 'right', 'justify'] | ColumnExpr | None = None

The text in a cell can be horizontally aligned though one of the following options: "center", "left", "right", or "justify".

v_align : Literal['middle', 'top', 'bottom'] | ColumnExpr | None = None

The vertical alignment of the text in the cell can be modified through the options "middle", "top", or "bottom".

style : Literal['normal', 'italic', 'oblique'] | ColumnExpr | None = None

Can be one of either "normal", "italic", or "oblique".

weight : Literal['normal', 'bold', 'bolder', 'lighter'] | ColumnExpr | None = None

The weight of the font can be modified thorough a text-based option such as "normal", "bold", "lighter", "bolder", or, a numeric value between 1 and 1000, inclusive. Note that only variable fonts may support the numeric mapping of weight.

stretch : Literal['normal', 'condensed', 'ultra-condensed', 'extra-condensed', 'semi-condensed', 'semi-expanded', 'expanded', 'extra-expanded', 'ultra-expanded'] | ColumnExpr | None = None

Allows for text to either be condensed or expanded. We can use one of the following text-based keywords to describe the degree of condensation/expansion: "ultra-condensed", "extra-condensed", "condensed", "semi-condensed", "normal", "semi-expanded", "expanded", "extra-expanded", or "ultra-expanded". Alternatively, we can supply percentage values from 0% to 200%, inclusive. Negative percentage values are not allowed.

decorate : Literal['overline', 'line-through', 'underline', 'underline overline'] | ColumnExpr | None = None

Allows for text decoration effect to be applied. Here, we can use "overline", "line-through", or "underline".

transform : Literal['uppercase', 'lowercase', 'capitalize'] | ColumnExpr | None = None

Allows for the transformation of text. Options are "uppercase", "lowercase", or "capitalize".

whitespace : Literal['normal', 'nowrap', 'pre', 'pre-wrap', 'pre-line', 'break-spaces'] | ColumnExpr | None = None

A white-space preservation option. By default, runs of white-space will be collapsed into single spaces but several options exist to govern how white-space is collapsed and how lines might wrap at soft-wrap opportunities. The options are "normal", "nowrap", "pre", "pre-wrap", "pre-line", and "break-spaces".

Returns

: CellStyleText

A CellStyleText object, which is used for a styles argument if specifying any cell text properties.

Examples

See GT.tab_style().