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!")
)
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",
...
}
}
)
If you want to modify the filter applied to the image, you could do this:
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)",
...
},
"filter": {
"background-color": "rgba(0, 0, 0, 0)" <- make the image not dimmed anymore
...
}
}
)
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
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
File details
Details for the file streamlit-card-0.0.7.tar.gz
.
File metadata
- Download URL: streamlit-card-0.0.7.tar.gz
- Upload date:
- Size: 671.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.17
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e47b1b2418527aa7770a664df2f4213bb2fb3fe034c92b5cc69f7a0b0b4695e |
|
MD5 | 5cf1b7b73327710897d2aa08850cb723 |
|
BLAKE2b-256 | 8101af3c229194ce28753ce801a88af2a66e45c6b5ff9bbb36da0e82ee91f6db |
File details
Details for the file streamlit_card-0.0.7-py3-none-any.whl
.
File metadata
- Download URL: streamlit_card-0.0.7-py3-none-any.whl
- Upload date:
- Size: 680.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.17
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 33802f389a4e5cf6823aebcc3b75715e2a571067d52bcbada2c5aed25674ffa3 |
|
MD5 | c3fcbce945b7bde1efec7a78ea870bd7 |
|
BLAKE2b-256 | 204461342eb87896e9d517ee3b43cfa5e46174fadd18ed88343ad8921f1b7848 |