How do I enhance an existing streamlit component

Hello.

I would like to use a link_button instead of a button in my app but I want to capture if the link_button has been pressed and if so, execute some action.

The reason I need a link_button is because it does not force a rerun.

Basically I am asking of there is a way to “wrap” the link_button component and add basic functionality to return true or false if it has been clicked.

Thanks!

What kind of action? No action will be performed on the python side without a rerun.

If I understand it correctly, the beauty of link_button is it doesn’t force a rerun.

I have a scenario where I have a series of buttons right now (st.button), each button’s label is a URL and if a button has been pressed, it opens a tab with the URL but also does something that is UI independent (send feedback to an S3 bucket on AWS). I want to do the same but with a link_button.

Currently, the rerun forced by st.button is destroying the layout of the container all these buttons are a part of. If I do the same container with link_button(s) - the layout is undisturbed because there is no rerun (is my understanding). However, with link_button I lose the ability to submit the feedback because I don’t know that a link_button has been clicked.

The ugliness of it is that your application doesn’t know when the user clicks on it. That is what it returns None and takes no callback arguments.

That’s kind of what I said, isn’t it? :wink: I am looking for a way to “enhance” link_button to return a true/false if it was clicked. Or are you saying as soon as there is “feedback” from a component - rerun is forced?

Or do I need to write a whole new component?

Yes, that is how components communicate with the application.

That would work if you can perform the action using javascript in the browser, without talking to the python app.

Is there a way to “attach” javascript functions to existing components “live” - components like link_button or do I need to write a whole new link_button implementation of my own?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.