Display a metric in big bold font, with an optional indicator of how the metric changed.

Tip: If you want to display a large number, it may be a good idea to shorten it using packages like [millify](https://github.com/azaitsev/millify) or [numerize](https://github.com/davidsa03/numerize). E.g. 1234 can be displayed as 1.2k using st.metric("Short number", millify(1234)).

Function signature

st.metric(label, value, delta=None, delta_color="normal")

Parameters

label (str)

The header or Title for the metric

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.

delta_color (str)

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.

Was this page helpful?

editSuggest edits
forum

Still have questions?

Our forums are full of helpful information and Streamlit experts.