Skip to main content

Streamlit component that allows you to edit text/code in a convenient text area.

Project description

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

pip install streamlit-input-box

Usage instructions

Pretty straighforward.

text=input_box(
    min_lines=1,
    max_lines=5,
    just_once=False,
    on_submit=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.
  • on_submit: 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

import streamlit as st
from streamlit_input_box import input_box

state=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)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

streamlit-input-box-0.0.1.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

streamlit_input_box-0.0.1-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file streamlit-input-box-0.0.1.tar.gz.

File metadata

  • Download URL: streamlit-input-box-0.0.1.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for streamlit-input-box-0.0.1.tar.gz
Algorithm Hash digest
SHA256 984a02a89b5fb9c08e9fdef62365fd1ae4be58e693e7d58fcda95ba5dde63c89
MD5 482a0db662a56ae15afcdc3dccf52dc6
BLAKE2b-256 be15751fa94d523daf33c577bb3eb7fd185c63aa1e3402338a01069b87b88a3a

See more details on using hashes here.

File details

Details for the file streamlit_input_box-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for streamlit_input_box-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0bf101702b091b474338bdde39f441d4e5206916bb094a08291299531b8128f4
MD5 d5ac516bd6cb882f665d9d490d0009b6
BLAKE2b-256 c86442a34c6930a8ac5afd8e8bedbe9876a337e54e01170df87a70699eab4084

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page