Closed hortojac closed 1 year ago
That would be great! Are you currently working on that? I see you forked the repo
Yes, I forked the repo and I am currently working on implementing it, unless you would prefer too?
Oh no it's great I'm happy to let you do it, comment here if you want some help on anything
@hortojac any news on that callback feature?
Hi @philippeboyd I'm taking over this feature request, how do you imagine this would work?
Would you have imagine something like that?
from streamlit_card import card
card(
title="Hello World!",
text="Some description",
image="http://placekitten.com/200/300",
func=lambda: st.session_state["x"] = "foo"
)
Isn't it better to do this:
from streamlit_card import card
hasClicked = card(
title="Hello World!",
text="Some description",
image="http://placekitten.com/200/300",
)
if hasClicked:
st.session_state["x"] = "foo"
which is already implemented
Hi @gamcoh , personnaly I prefer the first option (but func
being renamed to on_click
) as it would go on par with Streamlit's button component.
from streamlit_card import card
card(
title="Hello World!",
text="Some description",
image="http://placekitten.com/200/300",
on_click=lambda: st.session_state["x"] = "foo",
)
done
I think having the ability to call a function when clicked would be a great feature. This would allow you to use the streamlit-extras switch page component for example when used in a function. Could add this feature as optional and if the URL argument is None then it would resort to the function call if present.