https://github.com/b4pt0r/streamlit_input_box
Streamlit component : stateful text area with input history that reinitializes to empty after submitting.
https://github.com/b4pt0r/streamlit_input_box
Last synced: 6 months ago
JSON representation
Streamlit component : stateful text area with input history that reinitializes to empty after submitting.
- Host: GitHub
- URL: https://github.com/b4pt0r/streamlit_input_box
- Owner: B4PT0R
- License: mit
- Created: 2023-12-27T09:17:50.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-01-14T21:31:18.000Z (over 1 year ago)
- Last Synced: 2024-03-14T21:45:36.725Z (over 1 year ago)
- Language: TypeScript
- Size: 178 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# streamlit-input-box
Streamlit component that allows you to edit text/code in a convenient auto-resizable text area.
Intended both for code and natural language input (no syntax highlighting implemented).
No text wrap and horizontal scrolling makes code editing easier.
It's state resets to empty automatically after submiting.
Manages its own history of inputs that can be navigated using Ctrl+up / Ctrl+down.
Colors adapt dynamically to the app's theme.## Installation instructions
```sh
pip install streamlit-input-box
```## Usage instructions
Pretty straighforward.
```python
text=input_box(
min_lines=1,
max_lines=5,
just_once=False,
callback=None,
args=(),
kwargs={},
key=None
)
```
Renders an auto-resizable text area.
Enter and Tab keystrokes behave as expected for text edition.
Ctrl+Enter or click the 'send' button to submit.
Returns the inputted text.Arguments:
- min/max_lines: minimal and maximal limits for auto-resizing of the input box.
- just_once: determines if the component will return the text only once after submiting (and then None), or on every rerun of the app.
- callback: optional callback passed to the component that will be called after submitting.
- args: optional tuple of arguments passed to the callback
- kwargs: optional dict of named arguments passed to the callback
- key: unique state identifier for your component## Example
```python
import streamlit as st
from streamlit_input_box import input_boxstate=st.session_state
if 'texts' not in state:
state.texts=[]text=input_box(min_lines=3,max_lines=10,just_once=True)
if text:
state.texts.append(text)for text in state.texts:
st.text(text)
```