Reference
Styles and components for enhancing the look of Streamlit apps at UNDP.
apply_style(title='UNDP')
Apply the styling based on UNDP Design System, including CSS rules and favicon.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
title |
str
|
The page title, shown in the browser tab. |
"UNDP"
|
Returns:
Type | Description |
---|---|
None
|
|
Source code in st_undp/__init__.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
|
author(src, name, title, href)
Author component.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
src |
str
|
Image |
required |
name |
str
|
Name of the author. |
required |
title |
str
|
Title of the author, typically a position. |
required |
href |
str
|
URL the component points to when clicked. |
required |
Returns:
Type | Description |
---|---|
None
|
|
Source code in st_undp/components.py
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
|
author_card(src, name, title, summary, href, link='view', width=4)
Author card component.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
src |
str
|
Image |
required |
name |
str
|
Name of the author. |
required |
title |
str
|
Title of the author, typically a position. |
required |
summary |
str
|
Summary text displayed below the author. |
required |
href |
str
|
URL the component points to when clicked. |
required |
link |
str
|
Text displayed below the summary, typically "READ MORE" or similar. |
'view'
|
width |
int
|
Component width using a 12-grid scheme. |
4
|
Returns:
Type | Description |
---|---|
None
|
|
Source code in st_undp/components.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
|
author_summary(src, name, title, summary)
Author summary component.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
src |
str
|
Image |
required |
name |
str
|
Name of the author. |
required |
title |
str
|
Title of the author, typically a position. |
required |
summary |
str
|
Summary text displayed below the author. |
required |
Returns:
Type | Description |
---|---|
None
|
|
Source code in st_undp/components.py
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
|
breadcrumb(items)
Breadcrumbs component.
The breadcrumbs are arranged in the same order as dictionary keys. Last item's value is ignored and can be set to None.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
items |
dict[str, str]
|
Mapping from names to URLs. |
required |
Returns:
Type | Description |
---|---|
None
|
|
Source code in st_undp/components.py
345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 |
|
content_card(src, caption, href, tag='news', width=12)
Content card component (with image).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
src |
str
|
Image |
required |
caption |
str
|
Caption text displayed below the image. |
required |
href |
str
|
URL the component points to when clicked. |
required |
tag |
str
|
Tag text shown above the image. |
"news"
|
width |
int
|
Component width using a 12-grid scheme. |
12
|
Returns:
Type | Description |
---|---|
None
|
|
Source code in st_undp/components.py
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 |
|
download_card(src, title, format, href, variant='default')
Download card component.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
src |
str | None
|
Image |
required |
title |
str
|
Title of the document displayed on the card. |
required |
format |
str
|
Format of the file displayed on the card, including file size, e.g., "PDF (800kb)". |
required |
href |
str
|
URL the component points to when clicked, typically a download link. |
required |
variant |
Literal['publication', 'card', 'default']
|
One of the three card variants. If "default", |
"default"
|
Returns:
Type | Description |
---|---|
None
|
|
Source code in st_undp/components.py
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 |
|
featured_card(src, title, summary, href, tag='news', width=12)
Featured card component.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
src |
str
|
Image |
required |
title |
str
|
Title displayed on the card in bold. |
required |
summary |
str
|
Summary text displayed below the title. |
required |
href |
str
|
URL the component points to when clicked. |
required |
tag |
str
|
Tag text shown above the title. |
"news"
|
width |
int
|
Component width using a 12-grid scheme. |
12
|
Returns:
Type | Description |
---|---|
None
|
|
Source code in st_undp/components.py
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 |
|
footer(columns='default')
Footer component.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
columns |
Literal['dfx', 'default'] | dict[str, dict[str, str]]
|
Either a literal specifying the type of the footer to use or a mapping from column titles to column items. |
"default"
|
Returns:
Type | Description |
---|---|
None
|
|
Source code in st_undp/components.py
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 |
|
header(title, subtitle, title_href=None, subtitle_href=None, pages=None, logo='undp')
Header component.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
title |
str
|
Title displayed in the header. |
required |
subtitle |
str
|
Subtitle displayed in the header below the title. |
required |
title_href |
str | None
|
URL assigned to the title. |
None
|
subtitle_href |
str | None
|
URL assigned to the subtitle. |
None
|
pages |
list[Page] | None
|
List of pages to add as navigation in the header. |
None
|
logo |
Literal['undp', 'pnud']
|
One of the two versions of the logo to use. |
"undp"
|
Returns:
Type | Description |
---|---|
None
|
|
Source code in st_undp/components.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 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 |
|
image_card(src, summary, href, width=12)
Image reveal card component.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
src |
str
|
Image |
required |
summary |
str
|
Summary text displayed below the image. |
required |
href |
str
|
URL the component points to when clicked. |
required |
width |
int
|
Component width using a 12-grid scheme. |
12
|
Returns:
Type | Description |
---|---|
None
|
|
Source code in st_undp/components.py
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 |
|
stats_card(value, title, text='')
Stats card component.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value |
int | float | str
|
Value to be displayed, typically a number, percent etc. |
required |
title |
str
|
Title to be displayed below the number. |
required |
text |
str
|
Additional smaller text to be displayed below the title. |
''
|
Returns:
Type | Description |
---|---|
None
|
|
Source code in st_undp/components.py
366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 |
|