Skip to main content

A Streamlit component for displaying GIFs with beautiful styling

Project description

🎬 Streamlit GIF Viewer Component

A custom Streamlit component for displaying GIFs with beautiful styling and smooth animations.

Features

  • ✨ Beautiful, modern UI with hover effects
  • 🎨 Automatic theme integration with Streamlit
  • 📐 Customizable width and height
  • 💬 Optional captions
  • 🔄 Loading states and error handling
  • 🎯 Simple, intuitive API

Installation

Development Mode

  1. Install the Python package:

    pip install -e .
    
  2. Install frontend dependencies:

    cd gif_viewer/frontend
    npm install
    
  3. Start the frontend dev server:

    npm start
    
  4. Run the Streamlit app (in another terminal):

    streamlit run example.py
    

Usage

import streamlit as st
from gif_viewer import gif_viewer

# Basic usage
gif_viewer(
    gif_url="https://media.giphy.com/media/example/giphy.gif",
    caption="My awesome GIF!"
)

# With custom dimensions
gif_viewer(
    gif_url="https://media.giphy.com/media/example/giphy.gif",
    caption="Resized GIF",
    width=300,
    height=200
)

API Reference

gif_viewer(gif_url, caption="", width=None, height=None, autoplay=True, loop=True, key=None)

Parameter Type Default Description
gif_url str required URL or path to the GIF image
caption str "" Optional caption below the GIF
width int None Width in pixels (uses natural width if None)
height int None Height in pixels (uses natural height if None)
autoplay bool True Whether to autoplay the animation
loop bool True Whether to loop the animation
key str None Unique identifier for the component

Returns

A dictionary containing:

  • loaded (bool): Whether the GIF has finished loading
  • playing (bool): Current playback state

Building for Production

  1. Build the frontend:

    cd gif_viewer/frontend
    npm run build
    
  2. Set _RELEASE = True in gif_viewer/__init__.py

  3. Build the package:

    python setup.py sdist bdist_wheel
    

License

MIT

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_gif_viewer_demo-0.1.0.tar.gz (98.8 kB view details)

Uploaded Source

Built Distribution

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

streamlit_gif_viewer_demo-0.1.0-py3-none-any.whl (97.7 kB view details)

Uploaded Python 3

File details

Details for the file streamlit_gif_viewer_demo-0.1.0.tar.gz.

File metadata

File hashes

Hashes for streamlit_gif_viewer_demo-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a88510f0795b9c3ada5c628a5ccdca40d6a1151d3b43f83c420e1843a1d2e32f
MD5 9cf86323999323f681dd8285b15eedff
BLAKE2b-256 88365e43ddc7a07aeae2d224eee791ab8fb8dedeeed8d4777e42f96220fe5545

See more details on using hashes here.

File details

Details for the file streamlit_gif_viewer_demo-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for streamlit_gif_viewer_demo-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 33337b9b1709c054b2f85d7ce422cc61ae8d5bc9a4ebcda04cb0ae0f88631cfb
MD5 1e9c58543e14d993546f844eff1a6103
BLAKE2b-256 becb22c50748a92cdb0b03205d2dffea6cf1bdd07177d0bc8612b48349e92909

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