β οΈΒ Β Metric Cards
Submitted by Chanin Nantasenamat
Summary
Restyle metrics as cards
Functions
style_metric_cards
Applies a custom style to st.metrics in the page
Parameters:
Name | Type | Description | Default |
---|---|---|---|
background_color |
str
|
Background color. Defaults to "#FFF". |
'#FFF'
|
border_size_px |
int
|
Border size in pixels. Defaults to 1. |
1
|
border_color |
str
|
Border color. Defaults to "#CCC". |
'#CCC'
|
border_radius_px |
int
|
Border radius in pixels. Defaults to 5. |
5
|
border_left_color |
str
|
Borfer left color. Defaults to "#9AD8E1". |
'#9AD8E1'
|
box_shadow |
bool
|
Whether a box shadow is applied. Defaults to True. |
True
|
Source code in src/streamlit_extras/metric_cards/__init__.py
Import:
- You should add this to the top of your .py file
Examples
example
def example():
col1, col2, col3 = st.columns(3)
col1.metric(label="Gain", value=5000, delta=1000)
col2.metric(label="Loss", value=5000, delta=-1000)
col3.metric(label="No Change", value=5000, delta=0)
style_metric_cards()