A streamlit component, to make UI cards
Project description
st-card
Streamlit Component, for a UI card
authors - @gamcoh @Pernod Ricard
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!")
)
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
streamlit-card-0.0.5.tar.gz
(670.9 kB
view hashes)
Built Distribution
streamlit_card-0.0.5-py3-none-any.whl
(679.8 kB
view hashes)
Close
Hashes for streamlit_card-0.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ccf13904b076d5d85618bb559cc1c1768874173f4f320e8e24a65b59f0d12342 |
|
MD5 | 7bfb16cc1bcd2022326e5fcdcb1c0f9f |
|
BLAKE2b-256 | e96ff436a7b91ee3a3e723e5fb25fe51e0ec366dc82a868d4187997ce979e765 |