Checklist
Summary
When using st.metric with sparklines (chart_data) inside st.container(horizontal=True), the metrics sometimes wrap to take up full rows instead of staying side-by-side. The behavior is non-deterministic and seems related to the interaction between chart sizing and flex layout.
Reproducible Code Example
import streamlit as st
with st.container(horizontal=True):
st.metric("Revenue", "$1.2M", "+12%", border=True, chart_data=[1,2,3,4,5,6,7], chart_type="line")
st.metric("Orders", "11k", "+8%", border=True, chart_data=[3,1,4,1,5,9,2], chart_type="bar")
st.metric("Customers", "8.5k", "+15%", border=True, chart_data=[2,3,2,4,3,5,4], chart_type="line")
st.metric("AOV", "$132", "+3%", border=True)
Steps To Reproduce
No response
Expected Behavior
All metrics stay in a single row.
Current Behavior
Metrics wrap to full-width rows (second screenshot). Behavior varies on page load/resize.
Is this a regression?
Debug info
- Streamlit version: 1.53.1
- Python version:
- Operating System: Apple
- Browser: Chrome
Additional Information
No response
Checklist
Summary
When using st.metric with sparklines (chart_data) inside st.container(horizontal=True), the metrics sometimes wrap to take up full rows instead of staying side-by-side. The behavior is non-deterministic and seems related to the interaction between chart sizing and flex layout.
Reproducible Code Example
Steps To Reproduce
No response
Expected Behavior
All metrics stay in a single row.
Current Behavior
Metrics wrap to full-width rows (second screenshot). Behavior varies on page load/resize.
Is this a regression?
Debug info
Additional Information
No response