import streamlit as st
def my_metric(label, value, bg_color, icon="fas fa-asterisk"):
fontsize = 18
valign = "left"
lnk = '<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.12.1/css/all.css" crossorigin="anonymous">'
bg_color_css = f'rgb({bg_color[0]}, {bg_color[1]}, {bg_color[2]}, 0.75)'
htmlstr = f"""<p style='background-color: {bg_color_css};
font-size: {fontsize}px;
border-radius: 7px;
padding-left: 12px;
padding-top: 18px;
padding-bottom: 18px;
line-height:25px;'>
<i class='{icon} fa-xs'></i> {value}
</style><BR><span style='font-size: 14px;
margin-top: 0;'>{label}</style></span></p>"""
st.markdown(lnk + htmlstr, unsafe_allow_html=True)
green = (0, 204, 102)
red = (204, 0, 102)
icon_error = "fas fa-bug"
icon_observation = "fas fa-asterisk"
my_metric("Observations", 123, green)
my_metric("Errors", 13, red, icon_error)
st.markdown("# In columns")
col1, col2 = st.columns(2)
with col1:
my_metric("Observations", 123, green, icon_observation)
with col2:
my_metric("Errors", 13, red, icon_error)