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,
    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

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.3.tar.gz (996.4 kB view details)

Uploaded Source

Built Distribution

streamlit_input_box-0.0.3-py3-none-any.whl (998.5 kB view details)

Uploaded Python 3

File details

Details for the file streamlit_input_box-0.0.3.tar.gz.

File metadata

  • Download URL: streamlit_input_box-0.0.3.tar.gz
  • Upload date:
  • Size: 996.4 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.3.tar.gz
Algorithm Hash digest
SHA256 5cc61e231939bb651ed26ed70e634721febc30ddd8cc4d566bc36eaaa52f44f7
MD5 23f9aa1ec7da468195d0d91d64cdadcf
BLAKE2b-256 99257ea89335587ea11158e946e68ab442c77152aeff5d79bb74ff5375d297cb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for streamlit_input_box-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 2f2a66d5d9dcaf4dbc5a594a739e9a35984689e9d897fd9809e3670ff7ce43f3
MD5 a43fe77e88279037a59b406048f6cc99
BLAKE2b-256 d865f2d05b9014f2ce6f0682f3b4bd46d4897ddfe9f8a74b7f53af664b3abbf4

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