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
-
Install the Python package:
pip install -e .
-
Install frontend dependencies:
cd gif_viewer/frontend npm install
-
Start the frontend dev server:
npm start -
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 loadingplaying(bool): Current playback state
Building for Production
-
Build the frontend:
cd gif_viewer/frontend npm run build
-
Set
_RELEASE = Trueingif_viewer/__init__.py -
Build the package:
python setup.py sdist bdist_wheel
License
MIT
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_gif_viewer_demo-0.1.0.tar.gz.
File metadata
- Download URL: streamlit_gif_viewer_demo-0.1.0.tar.gz
- Upload date:
- Size: 98.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a88510f0795b9c3ada5c628a5ccdca40d6a1151d3b43f83c420e1843a1d2e32f
|
|
| MD5 |
9cf86323999323f681dd8285b15eedff
|
|
| BLAKE2b-256 |
88365e43ddc7a07aeae2d224eee791ab8fb8dedeeed8d4777e42f96220fe5545
|
File details
Details for the file streamlit_gif_viewer_demo-0.1.0-py3-none-any.whl.
File metadata
- Download URL: streamlit_gif_viewer_demo-0.1.0-py3-none-any.whl
- Upload date:
- Size: 97.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
33337b9b1709c054b2f85d7ce422cc61ae8d5bc9a4ebcda04cb0ae0f88631cfb
|
|
| MD5 |
1e9c58543e14d993546f844eff1a6103
|
|
| BLAKE2b-256 |
becb22c50748a92cdb0b03205d2dffea6cf1bdd07177d0bc8612b48349e92909
|