Lots of tab components out there and we now have the streamlit official tabs component. Great! If however you are like me and in need of a dynamic tabs component, one that you can create and close like you would browser tabs, then here you go.
You can create a function that saves the tab titles and data users attach to them in some database and load them up when they visit the page:
Also, mobile support which has a more compact feel and a bouncy add tab button
Possibilities:
Can add saved tab titles to be loaded up for users to view their previously saved tabs
Change the add button via material icons (google)
Can limit the number of tabs a user can create
Can change the design of the tabs
When there is only one tab, the close button does not appear. This is because upon creating a new tab, the tab is active but value is not passed onto streamlit. So create some code to direct users to click on the tab to view content. Wanted to limited the use of Streamlit’s api to send values to the python as it creates buggy behaviour in the component.
I have a rookie question: If the end-user can create tabs at runtime, how can the application post matter/ data / some text within these on-the-fly created tab containers?
I have updated the package to be able to do this. Ver 0.0.3 also sends the deletedtab object so that you can remove it from your database. View the demo which has been updated.
Note that github is not updating the data.json file but in an environment where this is capable, like in your local environment, it should work properly.
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.