bootstack.style.Theme#
- class bootstack.style.Theme(name, primary=None, success=None, info=None, warning=None, danger=None, secondary=None, neutral='#adb5bd', light=None, dark=None, surfaces=None, display_name=None, white='#ffffff', black='#000000')#
Bases:
objectA color theme family declared in code.
Declare the semantic accent colors as
[500]anchors plus alightand/ordarkblock (background/foreground). Each accent generates a 50–950 ramp; the framework picks the per-mode step for solids, washes, borders, and emphasis text.install()registers the generated<name>-lightand<name>-darkvariants.- Parameters:
name (str) – Family name; generated variants are
<name>-light/<name>-dark.primary (str | None) – Primary accent color (the
[500]ramp midpoint), as hex.success (str | None) – Success accent color (hex).
info (str | None) – Info accent color (hex).
warning (str | None) – Warning accent color (hex).
danger (str | None) – Danger accent color (hex).
secondary (str | None) – Optional colored secondary accent (hex). When omitted,
secondaryderives from the neutral ramp.neutral (str) – Gray base for the neutral ramp (borders, muted text, secondary).
light (dict[str, str] | None) –
{'background': ..., 'foreground': ...}for the light variant, or None to skip it.dark (dict[str, str] | None) –
{'background': ..., 'foreground': ...}for the dark variant.surfaces (dict | None) – Optional surface overrides — either a flat
{'chrome': '#...'}(both modes) or per-mode{'light': {...}, 'dark': {...}}. Pins surfaces the auto-derivation can’t produce well (e.g. chrome on a very-dark background).display_name (str | None) – Human label base; the mode is appended (` Light`/` Dark`).
white (str) – Reference white. Defaults to
'#ffffff'.black (str) – Reference black. Defaults to
'#000000'.
- classmethod from_existing(base, *, name, **overrides)#
Derive a new theme from an existing one, overriding only some tokens.
Every token you don’t override is inherited from
base, so you can brand a built-in family by changing just itsprimary(and any others you want):Theme.from_existing(“bootstrap”, name=”acme”, primary=”#ff5722”).install() bs.set_theme(“acme-light”)
- Parameters:
base (str | Theme) – The theme to build on — a built-in or already-installed family name (e.g.
'bootstrap'), or aThemeinstance. Required.name (str) – Family name for the derived theme; its
install()registers<name>-light/<name>-dark. Required.**overrides – Any
Themetoken to replace (primary,neutral,light,dark,surfaces,display_name, …).
- Returns:
A new
Theme; callinstall()on it to register its variants.- Raises:
ThemeError – If
basenames a theme family that is not registered, or an override names a token that is not aThemefield.- Return type:
- install(*, activate=False)#
Register the generated variants so they can be activated by name.
- variants()#
Return the generated per-mode schema dicts (light first, then dark).