Skip to content

Commit 3d42ac6

Browse files
authored
Add example app source files for st.pagination (#1492)
Add widget.pagination.py (basic usage) and widget.pagination_dataframe.py (paginated dataframe) to support the embedded app demos referenced in the st.pagination docstring at doc-pagination.streamlit.app and doc-pagination-dataframe.streamlit.app. Co-authored-by: blackary <>
1 parent dae8c09 commit 3d42ac6

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import streamlit as st
2+
3+
page = st.pagination(num_pages=10)
4+
st.write(f"Showing page {page}")
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import streamlit as st
2+
import pandas as pd
3+
4+
df = pd.DataFrame({"A": range(100), "B": range(100, 200)})
5+
rows_per_page = 10
6+
total_pages = (len(df) + rows_per_page - 1) // rows_per_page
7+
8+
# Use placeholders to show dataframe above pagination
9+
dataframe_slot = st.empty()
10+
with st.container(horizontal_alignment="right"):
11+
page = st.pagination(num_pages=total_pages)
12+
13+
start_idx = (page - 1) * rows_per_page
14+
end_idx = start_idx + rows_per_page
15+
dataframe_slot.dataframe(df.iloc[start_idx:end_idx])

0 commit comments

Comments
 (0)