Is there a way or workaround for st.metric to show the arrow down with a positive value?
st.metric(“Prod”, value=500, delta=100, delta_color=“normal”)
Is there a way or workaround for st.metric to show the arrow down with a positive value?
st.metric(“Prod”, value=500, delta=100, delta_color=“normal”)
Using a CSS selector, you could rotate the little svg drawing the arrow
import streamlit as st
st.markdown(
'''
<style>
[data-testid="stMetricDelta"] svg {
transform: rotate(180deg);
}
</style>
''',unsafe_allow_html=True)
cols = st.columns(2)
with cols[0]: st.metric("Positive metric", 100.0, 10)
with cols[1]: st.metric("Negative metric", 200.0, -10)
import streamlit as st
st.markdown(
'''
<style>
[data-testid="stMetricDelta"] svg {
animation: 2s infinite normal;
animation-name: spinny;
animation-timing-function: linear;
}
@keyframes spinny {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
</style>
''',unsafe_allow_html=True)
cols = st.columns(2)
with cols[0]: st.metric("Positive metric", 100.0, 10)
with cols[1]: st.metric("Negative metric", 200.0, -10)
I love it