Skip to content

Schema Contract: Color

Required columns

  • color (optional)

The column is detected once at model initialisation. If it is absent the entire coloring path is skipped.

Color encoding

Each cell in the color column is parsed by parse_color() and may be any of the following:

Format Example
Hex string "#ff8800"
RGB int tuple (255, 136, 0)
RGBA int tuple (255, 136, 0, 200) — alpha 0–255
RGB float tuple (1.0, 0.53, 0.0)
RGBA float tuple (1.0, 0.53, 0.0, 0.8)
Comma-separated string "255,136,0"

None means no color (default background).

Row coloring vs. per-cell coloring

The type of the value determines the scope.

Whole row — set color to a string or tuple:

table["color"] = "#aee8f5"        # hex string
table["color"] = (174, 232, 245)  # int-RGB tuple

Individual cells — set color to a dict mapping column name to a color value:

table["color"] = {"mz": "#ff0000", "rt": (0, 200, 0)}

Columns absent from the dict (or rows where color is None) render with the default background. Dict values are parsed by the same parse_color() function, so all formats above are accepted.

Selection highlight

When a row is selected the background color is desaturated to 50 % saturation in HSV space, keeping the hue visible while making the selection state clear.