Skip to main content

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

  1. Swipe right 💚 or click the like button to like a card
  2. Swipe left ❌ or click the pass button to pass on a card
  3. Click back ↶ to undo your last action
  4. Cards stack behind each other for a realistic experience
  5. Smooth animations provide visual feedback

Released under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

streamlit_swipecards-0.2.0.tar.gz (19.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

streamlit_swipecards-0.2.0-py3-none-any.whl (19.3 kB view details)

Uploaded Python 3

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

Hashes for streamlit_swipecards-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d6c7f2da125076684cafa0eb39345ebc0315f4d413c053afa8829d7a2702ff15
MD5 f4ad7d49872876f78365255fbe020396
BLAKE2b-256 120f67c6ddcfce0733b723f8dbff804317e97d6e197ddb8457bcd7fcf310ff58

See more details on using hashes here.

File details

Details for the file streamlit_swipecards-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for streamlit_swipecards-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 aa58205cc873a567dc6cb84914c39c27f371edc026801d75ae90fe325d0fd3b8
MD5 372165d66527ae2ad95f371e451fc4d0
BLAKE2b-256 f4fbce204bdfd7f68d9a3dba6793cf0da75f3aba1914544a233a1e1f6498a265

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page