Streamlit Swipecards allow you to add interactive swipeable cards to your app. Supports both image cards and table row swiping with cell highlighting.
Project description
Streamlit Swipe Cards
A modern card-swiping component for Streamlit. Build swipe interfaces using images or rows from a data table.
Features
- Stacked card interface with smooth animations
- Works on both touch and mouse devices
- Like, pass and undo actions
- Optional table view powered by AG‑Grid
- Cell, row and column highlighting support
- Automatic table caching for improved performance when loading the same dataset multiple times
Installation
pip install streamlit-swipecards
Quick demo
Launch the sample app to see both modes in action:
streamlit run example.py
Usage
Image cards
import streamlit as st
from streamlit_swipecards import streamlit_swipecards
cards = [
{"name": "Alice", "description": "Loves hiking", "image": "https://.../alice.jpg"\},
{"name": "Bob", "description": "Chef and foodie", "image": "https://.../bob.jpg"\},
]
result = streamlit_swipecards(cards=cards, display_mode="cards", key="people")
if result:
st.json(result)
Table cards
Provide a list of card dictionaries. Each card points to the dataset and the row it should display. Highlighting and centering options are set per card.
csv_path = "sample_data.csv"
cards = [
{
"dataset_path": csv_path,
"row_index": 0,
"name": "Alice Johnson",
"description": "Engineering professional from New York",
"highlight_cells": [{"row": 0, "column": "Salary", "color": "#FFB6C1"}],
"center_table_row": 0,
"center_table_column": "Salary",
},
{
"dataset_path": csv_path,
"row_index": 1,
"name": "Bob Smith",
"description": "Sales professional from California",
"highlight_cells": [{"row": 1, "column": "Rating", "color": "#98FB98"}],
"center_table_row": 1,
"center_table_column": "Rating",
},
]
result = streamlit_swipecards(cards=cards, display_mode="table", key="table")
if result:
st.json(result)
Card dictionaries
Image card
{
"name": "Alice", # required
"description": "Text", # required
"image": "URL or base64"
}
Table card
{
"dataset_path": "data.csv", # required
"row_index": 0, # row to display
"name": "Row title", # optional
"description": "Row description", # optional
"highlight_cells": [{"row": 0, "column": "Salary", "color": "#FFB6C1"}],
"highlight_rows": [{"row": 0, "color": "#E3F2FD"}],
"highlight_columns": [{"column": "Rating", "color": "#E8F5E8"}],
"center_table_row": 0,
"center_table_column": "Salary"
}
API reference
streamlit_swipecards(
cards=None,
dataset_path=None, # legacy single-dataset mode
highlight_cells=None,
highlight_rows=None,
highlight_columns=None,
display_mode="cards", # "cards" or "table"
center_table_row=None,
center_table_column=None,
key=None,
)
Return value
The component returns a dictionary:
{
"swipedCards": [{"index": 0, "action": "right"}, ...],
"lastAction": {"cardIndex": 0, "action": "right"},
"totalSwiped": 3,
"remainingCards": 7
}
How to Use
- Swipe right 💚 or click the like button to like a card
- Swipe left ❌ or click the pass button to pass on a card
- Click back ↶ to undo your last action
- Cards stack behind each other for a realistic experience
- Smooth animations provide visual feedback
Performance
The component automatically caches loaded datasets to improve performance when multiple cards reference the same file. This means:
- No redundant file reads: The same dataset file is only loaded once, even if multiple cards use it
- Automatic cache invalidation: When a file is modified, the cache is automatically updated
- Memory efficient: Uses Streamlit's built-in
@st.cache_datafor optimal memory management
To see the performance benefits in action, run:
python demo_caching.py
Released under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file streamlit_swipecards-0.2.6.tar.gz.
File metadata
- Download URL: streamlit_swipecards-0.2.6.tar.gz
- Upload date:
- Size: 23.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
46d3ef31de98b5bf2d906cbc59cca8a54175f155a32ec179676812c4ad5ec7cf
|
|
| MD5 |
1ee673f5868dacc49c1861b58cd55478
|
|
| BLAKE2b-256 |
64d3708a15cd081e0175facf4d0f551790593218ee4d6920c40dceb13aa6c049
|
File details
Details for the file streamlit_swipecards-0.2.6-py3-none-any.whl.
File metadata
- Download URL: streamlit_swipecards-0.2.6-py3-none-any.whl
- Upload date:
- Size: 22.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d49fb5956ec1a8e9e114e1b757f17b7f431d0030c788769c510d0e5413c75f92
|
|
| MD5 |
cab2398a439d44cf60d9dabfc9f3d556
|
|
| BLAKE2b-256 |
9f4df1f16b747b7c5581a6f625bee411174c9aee7f1fcd4e9a632fde658dab88
|