Skip to main content

A Streamlit custom component to load Lottie animations

Project description

Streamlit Lottie

Streamlit App

Integrate Lottie animations inside your Streamlit app!

Install

pip install streamlit-lottie

Usage

  • Basic usage
import streamlit as st
from streamlit_lottie import st_lottie

with st.echo():
    st_lottie("https://assets5.lottiefiles.com/packages/lf20_V9t630.json")
  • Basic usage (with monkey patched st.lottie function)
import streamlit as st
import streamlit_lottie

with st.echo():
    st.lottie("https://assets5.lottiefiles.com/packages/lf20_V9t630.json")
  • Context manager usage, using with notation
import time

import streamlit as st
from streamlit_lottie import st_lottie

with st_lottie("https://assets5.lottiefiles.com/packages/lf20_V9t630.json"):
    time.sleep(5)
  • Download lottie manually example
import time
import requests

import streamlit as st
from streamlit_lottie import st_lottie
from streamlit_lottie import st_lottie_spinner


def load_lottieurl(url: str):
    r = requests.get(url)
    if r.status_code != 200:
        return None
    return r.json()


lottie_url_hello = "https://assets5.lottiefiles.com/packages/lf20_V9t630.json"
lottie_url_download = "https://assets4.lottiefiles.com/private_files/lf30_t26law.json"
lottie_hello = load_lottieurl(lottie_url_hello)
lottie_download = load_lottieurl(lottie_url_download)


st_lottie(lottie_hello, key="hello")

if st.button("Download"):
    with st_lottie_spinner(lottie_download, key="download"):
        time.sleep(5)
    st.balloons()

Development

Install

  • JS side
cd frontend
npm install
  • Python side
conda create -n streamlit-lottie python=3.7
conda activate streamlit-lottie
pip install -e .

Run

Both webpack dev server and Streamlit need to run for development mode.

  • JS side
cd frontend
npm run start
  • Python side
streamlit run app.py

References

Support me

Buy Me A Coffee

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-lottie-0.0.5.tar.gz (792.6 kB view details)

Uploaded Source

Built Distribution

streamlit_lottie-0.0.5-py3-none-any.whl (802.4 kB view details)

Uploaded Python 3

File details

Details for the file streamlit-lottie-0.0.5.tar.gz.

File metadata

  • Download URL: streamlit-lottie-0.0.5.tar.gz
  • Upload date:
  • Size: 792.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.16

File hashes

Hashes for streamlit-lottie-0.0.5.tar.gz
Algorithm Hash digest
SHA256 c61589fb92bdf1dd5bd0a2ea75315d92e3383f46059b3704515d096a1e953d79
MD5 cc8ae7736c2072f2b17d07003e6902a9
BLAKE2b-256 4bd4e13ac9bde5b81b308d061092a420008af78c8b08547739423195596452d8

See more details on using hashes here.

File details

Details for the file streamlit_lottie-0.0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for streamlit_lottie-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 98656d6f1cc99c5d96fb8329bafbcdbb65709ad0a05176dffdf4755f6fc04cff
MD5 580e3d784bad8205ffdec9e29aa02b22
BLAKE2b-256 52b58ad7fa3101ec5baed712107a4cf304f174261f2ed2bebe063ad1fbedfe88

See more details on using hashes here.

Supported by

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