Caption in Streamlit

In Streamlit, a caption is used to display small, secondary text — typically for notes, sources, image credits, or subtle explanations. It appears in a lighter, smaller font compared to normal text.

Example: Caption for Data Source.

Python

import streamlit as st
import pandas as pd

# Create sample data
data = {"Name": ["Ashish", "Ravi"], "Score": [85, 90]}

# Convert dictionary to DataFrame
df = pd.DataFrame(data)

# Display table
st.dataframe(df)

# Display caption below the table
st.caption("Dataset: Sample student scores")    

The output of the above code is shown below:

Caption in Streamlit