Build Modern Streamlit Apps With shadcn UI Components
Streamlit’s built-in widgets all share one look. The streamlit-shadcn-ui package adds shadcn components to Streamlit, such as metric cards, tabs, switches, select boxes and date pickers, so an app looks less like a default Streamlit app. Below is a complete sales dashboard built with it, updated for the current 1.x release.
What shadcn is
shadcn/ui is a collection of accessible, customizable React components that front-end developers use in Next.js apps. Its cards, tabs and inputs look quite different from Streamlit’s defaults, and streamlit-shadcn-ui wraps many of them as Streamlit components you call from Python.

Install
Install the package with pip. The current release needs a recent Streamlit; the dashboard repository pins streamlit-shadcn-ui 1.5.0 with Streamlit 1.60 or newer.
pip install streamlit-shadcn-ui
The video uses version 0.1.18. Version 1.0 renamed several arguments, so code from the video stops with a TypeError on the current release. The code in this post uses the new names (Video = 0.1.18, Now = 1.x):
| Call | Video | Now |
|---|---|---|
ui.metric_card |
title, content |
label, value |
ui.tabs |
default_value |
value |
ui.switch |
default_checked |
value |
The card_container helper from the video came from a local_components module that only shipped with 0.1.18. On current Streamlit, st.container(border=True) gives the chart the same card-style frame.
A sales dashboard
The example dashboard shows total sales per city with the change against the previous year, and a bar chart that groups one city’s sales by month or by product category. Tabs switch the grouping, a select box picks the city, and a switch shows the previous year.

The script reads the sales data from a CSV on GitHub and caches it, sums the revenue per city and year, and shows one metric card per city. The chart is a Vega-Lite spec instead of st.bar_chart, because Vega-Lite can round the bar corners. This is the complete app from the repository:
import streamlit as st
import pandas as pd
import streamlit_shadcn_ui as ui
# CONFIGS
YEAR = 2023
PREVIOUS_YEAR = 2022
CITIES = ["Tokyo", "Yokohama", "Osaka"]
DATA_URL = "https://raw.githubusercontent.com/Sven-Bo/datasets/master/store_sales_2022-2023.csv"
BAR_CHART_COLOR = "#000000"
st.set_page_config(page_title="Sales Dashboard", page_icon="📈")
st.title(f"Sales Dashboard", anchor=False)
hide_st_style = """
<style>
#MainMenu {visibility: hidden;}
header {visibility: hidden;}
</style>
"""
st.markdown(hide_st_style, unsafe_allow_html=True)
@st.cache_data
def get_and_prepare_data(data):
df = pd.read_csv(data).assign(
date_of_sale=lambda df: pd.to_datetime(df["date_of_sale"]),
month=lambda df: df["date_of_sale"].dt.month,
year=lambda df: df["date_of_sale"].dt.year,
)
return df
df = get_and_prepare_data(data=DATA_URL)
# Calculate total revenue for each city and year, and then calculate the percentage change
city_revenues = (
df.groupby(["city", "year"])["sales_amount"]
.sum()
.unstack()
.assign(change=lambda x: x.pct_change(axis=1)[YEAR] * 100)
)
# Display the data for each city in separate columns
columns = st.columns(3)
for i, city in enumerate(CITIES):
with columns[i]:
ui.metric_card(
label=city,
value=f"$ {city_revenues.loc[city, YEAR]:,.2f}",
description=f"vs. Last Year: {city_revenues.loc[city, 'change']:.2f}% change",
key=f"card{i}",
)
analysis_type = ui.tabs(
options=["Month", "Product Category"],
value="Month",
key="analysis_type",
)
# Dropdown for selecting a city
selected_city = ui.select("Select a city:", CITIES, key="selected_city")
# Toggle for selecting the year for visualization
previous_year_toggle = ui.switch(
label="Previous Year", value=False, key="switch_visualization"
)
visualization_year = PREVIOUS_YEAR if previous_year_toggle else YEAR
# Display the year above the chart based on the toggle switch
st.write(f"**Sales for {visualization_year}**")
# Filter data based on selection for visualization
if analysis_type == "Product Category":
filtered_data = (
df.query("city == @selected_city & year == @visualization_year")
.groupby("product_category", dropna=False)["sales_amount"]
.sum()
.reset_index()
)
else:
# Group by month number
filtered_data = (
df.query("city == @selected_city & year == @visualization_year")
.groupby("month", dropna=False)["sales_amount"]
.sum()
.reset_index()
)
# Ensure month column is formatted as two digits for consistency
filtered_data["month"] = filtered_data["month"].apply(lambda x: f"{x:02d}")
# Display the data
vega_spec = {
"mark": {"type": "bar", "cornerRadiusEnd": 4},
"encoding": {
"x": {
"field": filtered_data.columns[0],
"type": "nominal",
"axis": {
"labelAngle": 0,
"title": None, # Hides the x-axis title
"grid": False, # Removes the x-axis gridlines
},
},
"y": {
"field": "sales_amount",
"type": "quantitative",
"axis": {
"title": None, # Hides the y-axis title
"grid": False, # Removes the y-axis gridlines
},
},
"color": {"value": BAR_CHART_COLOR},
},
"data": {
"values": filtered_data.to_dict(
"records"
) # Convert DataFrame to a list of dictionaries
},
}
# Card-style frame around the chart (replaces local_components.card_container)
with st.container(border=True):
st.vega_lite_chart(vega_spec, width="stretch")
Run it with streamlit run streamlit_app.py. If you only want to restyle Streamlit’s own widgets, custom CSS through widget keys is the lighter option.
Limits
When I recorded this, the components did not support Streamlit’s dark theme well: the white cards stood out, the switch was hard to see, and the select box showed extra whitespace. The package works best with Streamlit’s light theme.

Streamlit has added new built-in elements since then, which I cover in five newer Streamlit features.
