st.metric(label, value, delta=None, delta_color="normal", help=None, label_visibility="visible")
The header or title for the metric. The label can optionally contain Markdown and supports the following elements: Bold, Italics, Strikethroughs, Inline Code, Emojis, and Links.
This also supports:
value (int, float, str, or None)
Value of the metric. None is rendered as a long dash.
delta (int, float, str, or None)
Indicator of how the metric changed, rendered with an arrow below the metric. If delta is negative (int/float) or starts with a minus sign (str), the arrow points down and the text is red; else the arrow points up and the text is green. If None (default), no delta indicator is shown.
If "normal" (default), the delta indicator is shown as described above. If "inverse", it is red when positive and green when negative. This is useful when a negative change is considered good, e.g. if cost decreased. If "off", delta is shown in gray regardless of its value.
An optional tooltip that gets displayed next to the metric label.
label_visibility ("visible" or "hidden" or "collapsed")
The visibility of the label. If "hidden", the label doesn't show but there is still empty space for it (equivalent to label=""). If "collapsed", both the label and the space are removed. Default is "visible". This argument can only be supplied by keyword.
import streamlit as st st.metric(label="Temperature", value="70 °F", delta="1.2 °F")(view standalone Streamlit app)
st.metric looks especially nice in combination with st.columns:import streamlit as st col1, col2, col3 = st.columns(3) col1.metric("Temperature", "70 °F", "1.2 °F") col2.metric("Wind", "9 mph", "-8%") col3.metric("Humidity", "86%", "4%")(view standalone Streamlit app)
The delta indicator color can also be inverted or turned off:import streamlit as st st.metric(label="Gas price", value=4, delta=-0.5, delta_color="inverse") st.metric(label="Active developers", value=123, delta=123, delta_color="off")(view standalone Streamlit app)