constants
pinky_streamlit.constants
Shared constants for the design system: color palette and icon registry.
Usage::
from pinky_streamlit import ICONS, PALETTE
st.badge("", icon=ICONS.SUCCESS.material) # :material/check_circle:
st.badge("✅", icon=ICONS.SUCCESS.emoji) # ✅
st.badge("", icon=str(ICONS.SUCCESS)) # same as .material (default)
ICONS
Kit icon registry — subclass to add app-specific icons.
Access via ICONS.<NAME>.material or ICONS.<NAME>.emoji.
Source code in src/pinky_streamlit/core/constants.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | |
Icon
dataclass
A design-system icon with both a Material Symbol and an emoji variant.
str(icon) returns the material string — safe to pass to any Streamlit
argument that accepts a Material Symbol (icon=, st.badge, st.button…).
Use .emoji for components that don't support :material/…: syntax.
To extend the registry with app-specific icons, subclass ICONS::
from pinky_streamlit import ICONS, Icon
class MyIcons(ICONS):
CAT = Icon(":material/pets:", "🐱")
RABBIT = Icon(":material/cruelty_free:", "🐰")
Source code in src/pinky_streamlit/core/constants.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | |
PALETTES
Pre-built color palettes — subclass to add app-specific themes.
Access via PALETTES.PYTHIA, PALETTES.STREAMLIT, etc.
Pass to setup_page(palette=PALETTES.PYTHIA) to activate.
Dark mode is auto-computed unless overridden via dark=PaletteColors(...).
To extend with custom palettes, subclass PALETTES::
from pinky_streamlit import PALETTES, Palette, PaletteColors
class AppPalettes(PALETTES):
MY_BRAND = Palette(
light=PaletteColors(primary="#6200ea", secondary="#00bcd4", tertiary="#76ff03"),
)
Source code in src/pinky_streamlit/core/constants.py
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 | |
Palette
dataclass
A complete theme with light and dark color sets.
Pass to setup_page(palette=...) to inject brand colors as CSS variables.
All color-mix() shades in style.css are derived automatically from these
base colors — no CSS file needs editing.
Usage::
from pinky_streamlit import PALETTES, setup_page
messages, main, df = setup_page(session, loaders=[...], palette=PALETTES.APPLE)
Extend with a custom palette::
from pinky_streamlit import Palette, PaletteColors
# Dark auto-computed from light
MY_PALETTE = Palette(
light=PaletteColors(primary="#6200ea", secondary="#00bcd4", tertiary="#76ff03"),
)
# Full control over dark variant
MY_PALETTE = Palette(
light=PaletteColors(primary="#6200ea", secondary="#00bcd4", tertiary="#76ff03"),
dark=PaletteColors( primary="#b388ff", secondary="#80deea", tertiary="#ccff90"),
)
Source code in src/pinky_streamlit/core/constants.py
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | |
to_config_toml(font_files=None)
Generate .streamlit/config.toml content from this palette.
For Streamlit Container Runtime apps: sets primaryColor natively
for both light and dark themes. This fixes the KNOWN LIMITATIONS in
style.css (slider track fill, date picker selected day) that
cannot be overridden via CSS — Streamlit now applies the color
at the React level.
setup_page() still injects style.css + CSS variables for the
full design system (--primary-darker, color-mix() shades,
component overrides). This method handles what config.toml
can absorb; CSS handles the rest.
Font injection via base64 (AppFont) is no longer needed in
Container Runtime — pass font files instead and set font=None
in setup_page().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
font_files
|
list[str] | None
|
Project-relative paths to font files to bundle
(e.g. |
None
|
Returns:
| Type | Description |
|---|---|
str
|
String content to write to |
Example::
from pinky_streamlit import PALETTES
toml = PALETTES.PYTHIA.to_config_toml(
font_files=["static/DMSans.woff2"]
)
# Write to .streamlit/config.toml in your app project.
Source code in src/pinky_streamlit/core/constants.py
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | |
PaletteColors
dataclass
Color set for one mode (light or dark).
primary, secondary, tertiary are the brand accent colors.
Semantic colors default to the pythia theme values and are usually kept
stable across themes.
Source code in src/pinky_streamlit/core/constants.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | |