Skip to main content

A streamlit component, to make UI cards

Project description

st-card

Streamlit Component, for a UI card

authors - @gamcoh @Pernod Ricard

image

Installation

Install streamlit-card with pip

pip install streamlit-card

usage, import the card function from streamlit_card

from streamlit_card import card

hasClicked = card(
  title="Hello World!",
  text="Some description",
  image="http://placekitten.com/200/300",
  url="https://github.com/gamcoh/st-card"
)

You can also use a local image by doing this instead

import base64

with open(filepath, "rb") as f:
    data = f.read()
    encoded = base64.b64encode(data)
data = "data:image/png;base64," + encoded.decode("utf-8")

from streamlit_card import card

hasClicked = card(
  title="Hello World!",
  text="Some description",
  image=data
  url="https://github.com/gamcoh/st-card"
)

You can also create a card without an URL. That way you control the behavior when the user click on it. For instance:

from streamlit_card import card

hasClicked = card(
  title="Hello World!",
  text="Some description",
  image="http://placekitten.com/200/300",
)

if hasClicked:
    # do something

If you want, you could use a callback to handle the click like so:

from streamlit_card import card

hasClicked = card(
  title="Hello World!",
  text="Some description",
  image="http://placekitten.com/200/300",
  on_click=lambda: print("Clicked!")
)

Customizations

If you want, you could use a callback to handle the click like so:

from streamlit_card import card

res = card(
    title="Streamlit Card",
    text="This is a test card",
    image="https://placekitten.com/500/500",
    styles={
        "card": {
            "width": "500px",
            "height": "500px",
            "border-radius": "60px",
            "box-shadow": "0 0 10px rgba(0,0,0,0.5)",
            ...
        },
        "text": {
            "font-family": "serif",
            ...
        }
    }
)

Multiple descriptions

from streamlit_card import card

res = card(
    title="Streamlit Card",
    text=["This is a test card", "This is a subtext"],
    image="https://placekitten.com/500/500",
)

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-card-0.0.6.tar.gz (671.7 kB view details)

Uploaded Source

Built Distribution

streamlit_card-0.0.6-py3-none-any.whl (680.5 kB view details)

Uploaded Python 3

File details

Details for the file streamlit-card-0.0.6.tar.gz.

File metadata

  • Download URL: streamlit-card-0.0.6.tar.gz
  • Upload date:
  • Size: 671.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.17

File hashes

Hashes for streamlit-card-0.0.6.tar.gz
Algorithm Hash digest
SHA256 8093132f5fd57fac5c58e16b8e7adca77d0894f96318265b9014004be66749eb
MD5 acd5903bbd052802e4b6b8ee3ec34fb8
BLAKE2b-256 e2fb579a10566c4c3517d7c615f1ab40e3d1a45a6f2b414b4f1559277b1fd9ee

See more details on using hashes here.

File details

Details for the file streamlit_card-0.0.6-py3-none-any.whl.

File metadata

File hashes

Hashes for streamlit_card-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 aed3f297ad9d74b5663915c021a20297613f6f710873a2295ce493abd54a0d09
MD5 5e5caf1c35d9d5cf2a0ccf9dc9e47ed2
BLAKE2b-256 9f09fad53d099c8f31f6a190948baed14aebc7298463fe2692657d2775393b5c

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