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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: streamlit_input_box-0.0.2.tar.gz
  • Upload date:
  • Size: 3.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.2.tar.gz
Algorithm Hash digest
SHA256 dc3b9394f7ec0ede21986cbca3fd3267d708f034991831b9241869763f70dc5b
MD5 36717924d04b9383b6767be686f0799d
BLAKE2b-256 e1cf74ba3dcf06c955c765a07f5d73f64614a7da8f86c88acc5d122d5dff457c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for streamlit_input_box-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a5dc629437f3b3da05b90030b04006293f4582605871a5923062900dbc680a71
MD5 10d35c002958082fdb1612f7ee1fff78
BLAKE2b-256 84aa382bd376babac3fe8c52675fce194cf483203fc548ba94ddcbcf2071eb8f

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