Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/0phoff/st-btn-select
Streamlit Button Select Component
https://github.com/0phoff/st-btn-select
component select streamlit
Last synced: 4 months ago
JSON representation
Streamlit Button Select Component
- Host: GitHub
- URL: https://github.com/0phoff/st-btn-select
- Owner: 0phoff
- License: mit
- Created: 2021-10-23T11:17:26.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-10-23T13:06:45.000Z (over 3 years ago)
- Last Synced: 2024-09-28T13:41:08.895Z (4 months ago)
- Topics: component, select, streamlit
- Language: Python
- Homepage: https://share.streamlit.io/0phoff/st-btn-select/demo/test.py
- Size: 52.7 KB
- Stars: 34
- Watchers: 1
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Version][version-badge]][version-url]
[![License][license-badge]][license-url]_Streamlit Button Select Component_
---
Sometimes you want a user to make a selection, but you only have a few options.
Using an `st.selectbox` component works, but wouldn't it be easier to simply have a few buttons in a row ?
Well, this custom component allows just that !# Installation
```bash
pip install st_btn_select
```# Getting Started
Creating a Button Selection is really easy.
```python
from st_btn_select import st_btn_selectselection = st_btn_select(('option 1', 'option 2', 'option 3'))
```You can also use this component as a small top navigation bar.
```python
from st_btn_select import st_btn_selectpage = st_btn_select(
# The different pages
('home', 'about', 'docs', 'playground'),
# Enable navbar
nav=True,
# You can pass a formatting function. Here we capitalize the options
format_func=lambda name: name.capitalize(),
)# Display the right things according to the page
if page == 'home':
st.write('HOMEPAGE')
```> **NOTE**
> There can only be one navbar per page, as they will be displayed on top of each other.
>
> The navbar buttons do not set any URL hashes, and thus the different pages are not bookmarkable, nor can you use the browser history.## Documentation
Check out this streamlit app for the documentation, as well as a demo.
[![Open in Streamlit][share-badge]][share-url][version-badge]: https://img.shields.io/pypi/v/st_btn_select?label=version
[version-url]: https://github.com/0phoff/st-btn-select/releases[license-badge]: https://img.shields.io/pypi/l/st_btn_select
[license-url]: https://github.com/0phoff/st-btn-select/blob/master/LICENSE.md[share-badge]: https://static.streamlit.io/badges/streamlit_badge_black_white.svg
[share-url]: https://share.streamlit.io/0phoff/st-btn-select/demo/test.py