Building Streamlit Dashboards
by streamlit
Building dashboards in Streamlit. Use when creating KPI displays, metric cards, or data-heavy layouts. Covers borders, cards, responsive layouts, and dashboard composition.
Skill Details
Repository Files
1 file in this skill directory
name: building-streamlit-dashboards description: Building dashboards in Streamlit. Use when creating KPI displays, metric cards, or data-heavy layouts. Covers borders, cards, responsive layouts, and dashboard composition. license: Apache-2.0
Streamlit dashboards
Compose metrics, charts, and data into clean dashboard layouts.
Cards with borders
Use border=True to create visual cards. Supported on st.container, st.metric, st.columns, and st.form:
# Container card
with st.container(border=True):
st.subheader("Sales Overview")
st.line_chart(sales_data)
# Metric card
st.metric("Revenue", "$1.2M", "+12%", border=True)
# Column cards
for col in st.columns(3, border=True):
with col:
st.metric("Users", "1.2k")
Card labels
Add context to cards with headers or bold text:
# With subheader
with st.container(border=True):
st.subheader("Monthly Trends")
st.line_chart(data)
# With bold label
with st.container(border=True):
st.markdown("**Top Products**")
st.dataframe(top_products)
KPI rows
Use horizontal containers for responsive metric rows:
with st.container(horizontal=True):
st.metric("Revenue", "$1.2M", "-7%", border=True)
st.metric("Users", "762k", "+12%", border=True)
st.metric("Orders", "1.4k", "+5%", border=True)
Horizontal containers wrap on smaller screens. Prefer them over st.columns for metric rows.
Metrics with sparklines
Add trend context with chart_data:
weekly_values = [700, 720, 715, 740, 762, 755, 780]
st.metric(
"Active Users",
"780k",
"+3.2%",
border=True,
chart_data=weekly_values,
chart_type="line", # or "bar"
)
Sparklines show y-values only—use for evenly-spaced data like daily/weekly snapshots.
Dashboard layout
Combine cards into a dashboard:
# KPI row
with st.container(horizontal=True):
st.metric("Revenue", "$1.2M", "-7%", border=True, chart_data=rev_trend, chart_type="line")
st.metric("Users", "762k", "+12%", border=True, chart_data=user_trend, chart_type="line")
st.metric("Orders", "1.4k", "+5%", border=True, chart_data=order_trend, chart_type="bar")
# Charts row
col1, col2 = st.columns(2)
with col1:
with st.container(border=True):
st.subheader("Revenue by Region")
st.bar_chart(region_data, x="region", y="revenue")
with col2:
with st.container(border=True):
st.subheader("Monthly Trend")
st.line_chart(monthly_data, x="month", y="value")
# Data table
with st.container(border=True):
st.subheader("Recent Orders")
st.dataframe(orders_df, hide_index=True)
Sidebar filters
Put filters in the sidebar to maximize dashboard space:
with st.sidebar:
date_range = st.date_input("Date range", value=(start, end))
region = st.multiselect("Region", regions, default=regions)
# Main area is all dashboard content
Related skills
using-streamlit-layouts: Columns, containers, tabs, dialogsdisplaying-streamlit-data: Charts, dataframes, column configurationoptimizing-streamlit-performance: Caching and fragments for heavy dashboards
References
Related Skills
Xlsx
Comprehensive spreadsheet creation, editing, and analysis with support for formulas, formatting, data analysis, and visualization. When Claude needs to work with spreadsheets (.xlsx, .xlsm, .csv, .tsv, etc) for: (1) Creating new spreadsheets with formulas and formatting, (2) Reading or analyzing data, (3) Modify existing spreadsheets while preserving formulas, (4) Data analysis and visualization in spreadsheets, or (5) Recalculating formulas
Clickhouse Io
ClickHouse database patterns, query optimization, analytics, and data engineering best practices for high-performance analytical workloads.
Clickhouse Io
ClickHouse database patterns, query optimization, analytics, and data engineering best practices for high-performance analytical workloads.
Analyzing Financial Statements
This skill calculates key financial ratios and metrics from financial statement data for investment analysis
Data Storytelling
Transform data into compelling narratives using visualization, context, and persuasive structure. Use when presenting analytics to stakeholders, creating data reports, or building executive presentations.
Kpi Dashboard Design
Design effective KPI dashboards with metrics selection, visualization best practices, and real-time monitoring patterns. Use when building business dashboards, selecting metrics, or designing data visualization layouts.
Dbt Transformation Patterns
Master dbt (data build tool) for analytics engineering with model organization, testing, documentation, and incremental strategies. Use when building data transformations, creating data models, or implementing analytics engineering best practices.
Sql Optimization Patterns
Master SQL query optimization, indexing strategies, and EXPLAIN analysis to dramatically improve database performance and eliminate slow queries. Use when debugging slow queries, designing database schemas, or optimizing application performance.
Anndata
This skill should be used when working with annotated data matrices in Python, particularly for single-cell genomics analysis, managing experimental measurements with metadata, or handling large-scale biological datasets. Use when tasks involve AnnData objects, h5ad files, single-cell RNA-seq data, or integration with scanpy/scverse tools.
Xlsx
Spreadsheet toolkit (.xlsx/.csv). Create/edit with formulas/formatting, analyze data, visualization, recalculate formulas, for spreadsheet processing and analysis.
