Is it possible to use a Shared Components when creating a Streamlit Component?
My use case if the following: I would like to create an “info alert” (st.sidebar.info("some text")) with a little tweak. The little tweak consists in adding a little icon to “copy” the text of the info alert when clicked.
Instead of recreating the JS and CSS from scratch, I wanted to import the shared component AlertContainer inside my MyComponent.tsx file and start from there.
But I failed to do so. It looks like the said Container is not in the streamlit-component-lib module.
Is there a way to do what I just described?
Good idea, I did not think of that! I tried it: the text is too long for the sidebar and a scroll bar appears and it’s cluttering the small space. It would have been great if there was an option for the text to appear on several lines like the st.sidebar.info.
I finally managed to do it using “\n” chars that are not copied to clipboard when pasting inside a browser but are copied when copying to a text file for example.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.