Skip to main content

Streamlit Swipecards allow you to add interactive swipeable cards to your app.

Project description

UNDER DEVELOPMENT! - NOT FULLY TESTED!

💕 Streamlit Swipe Cards

A swipe cards component for Streamlit! Create beautiful, interactive card interfaces with smooth swipe animations.

Features

  • 🎴 Stacked card interface - Cards stack behind each other
  • 👆 Touch & mouse support - Swipe with finger or mouse
  • 🎯 Three actions - Like (right), Pass (left), and Back
  • 🎨 Beautiful animations - Smooth swipe animations with visual feedback
  • 📱 Mobile responsive - Works great on all devices
  • 🖼️ Image support - Upload files or use URLs
  • Easy to use - Simple Python API

Installation instructions

pip install streamlit-swipecards

Usage

import streamlit as st
from streamlit_swipecards import streamlit_swipecards

# Define your cards
cards = [
    {
        "name": "Alice Johnson",
        "description": "Software Engineer who loves hiking and photography",
        "image": "https://example.com/alice.jpg"
    },
    {
        "name": "Bob Smith", 
        "description": "Chef and foodie exploring the world",
        "image": "https://example.com/bob.jpg"
    },
    {
        "name": "Carol Davis",
        "description": "Artist and musician exploring creativity",
        "image": "https://example.com/carol.jpg"
    }
]

# Create the swipe interface
result = streamlit_swipecards(cards=cards, key="swipe_cards")

# Handle the result
if result:
    st.write("### Last action:")
    st.json(result)

Card Data Format

Each card should be a dictionary with these required fields:

{
    "name": str,        # Person's name (required)
    "description": str, # Description text (required)
    "image": str       # Image URL or base64 data (required)
}

Quick Start

Run the example:

streamlit run example.py

This will launch a demo with three sample profiles using real Unsplash images, complete with instructions and action feedback.

Return Value

The component returns a comprehensive dictionary with all swipe session data:

{
    "swipedCards": [    
        {
            "card": {
                "name": "Alice",
                "description": "Loves hiking and photography",
                "image": "https://example.com/alice.jpg"
            },
            "action": "right", # "right" (like), "left" (pass), or "back" (undo)
            "index": 0 # Original index in the cards array
        },
        {
            "card": {
                "name": "Bob",
                "description": "Chef and food enthusiast", 
                "image": "https://example.com/bob.jpg"
            },
            "action": "right",
            "index": 1
        }
    ],
    "lastAction": {
        "card": {
            "name": "Bob",
            "description": "Chef and food enthusiast",
            "image": "https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?w=400&h=400&fit=crop&crop=faces"
        },
        "action": "right",
        "cardIndex": 1
    },
    "totalSwiped": 2, 
    "remainingCards": 1 
}

This comprehensive data structure allows you to:

  • Track all user interactions with swipedCards
  • React to the most recent action with lastAction
  • Display progress with totalSwiped and remainingCards
  • Build features like undo, analytics, or recommendation systems

You can use st.json(result) to display the full result object for debugging, as shown in the example above.

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

Made with ❤️ for the Streamlit community

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.1.4.tar.gz (12.4 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.1.4-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

Details for the file streamlit_swipecards-0.1.4.tar.gz.

File metadata

  • Download URL: streamlit_swipecards-0.1.4.tar.gz
  • Upload date:
  • Size: 12.4 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.1.4.tar.gz
Algorithm Hash digest
SHA256 508b28a137fff25cacc6377e4a2aa19bd66cf27f2044d93615ffcf00041ea4bf
MD5 729bdbe53857abb59d6962aff63cf798
BLAKE2b-256 6aa3c05d51ede6f8c583e80aefb62d3e7bc274d4f0dd2063acd45b2cc27139f7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for streamlit_swipecards-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a29dfe26ac06f1cac3dc3e83dbc9493dc51592a57914ec40b82b74fc4d33f753
MD5 5030ce90c2395afbdeb106f25ddf34d2
BLAKE2b-256 e32a98a929da506b32a9d3bb5410e59fef5e086db39d328cc2b8cd8b5ab93814

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