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
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
}
Use this information to build analytics, undo functionality or any custom logic.
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
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.0.tar.gz.
File metadata
- Download URL: streamlit_swipecards-0.2.0.tar.gz
- Upload date:
- Size: 19.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d6c7f2da125076684cafa0eb39345ebc0315f4d413c053afa8829d7a2702ff15
|
|
| MD5 |
f4ad7d49872876f78365255fbe020396
|
|
| BLAKE2b-256 |
120f67c6ddcfce0733b723f8dbff804317e97d6e197ddb8457bcd7fcf310ff58
|
File details
Details for the file streamlit_swipecards-0.2.0-py3-none-any.whl.
File metadata
- Download URL: streamlit_swipecards-0.2.0-py3-none-any.whl
- Upload date:
- Size: 19.3 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 |
aa58205cc873a567dc6cb84914c39c27f371edc026801d75ae90fe325d0fd3b8
|
|
| MD5 |
372165d66527ae2ad95f371e451fc4d0
|
|
| BLAKE2b-256 |
f4fbce204bdfd7f68d9a3dba6793cf0da75f3aba1914544a233a1e1f6498a265
|