Skip to main content

Streamlit autocomplete Textcomplete editor for HTMLTextAreaElement

Project description

Streamlit Textcomplete - Autocomplete text in any textarea

Streamlit Textcomplete is a custom Streamlit component designed to enhance text input fields with autocomplete functionality. It leverages the powerful textcomplete library to provide users with a seamless and intuitive autocomplete experience within Streamlit applications.

Demo

demo

Example Screencast

Features

  • Autocomplete for Text Areas: Enhance textarea in Streamlit with autocomplete functionality, making data input faster and more accurate.
  • Customizable Strategies: Define your own strategies for text autocomplete, including username mentions, emoji suggestions, and more.
  • Easy Integration: Seamlessly integrates with existing Streamlit applications with minimal setup.
  • Flexible and Extensible: Easily extend the component to support additional autocomplete strategies as per your application's needs.

Installation

To install Streamlit Textcomplete, run the following command in your terminal:

pip install streamlit-textcomplete

Usage

To use Streamlit Textcomplete in your Streamlit application, follow these steps:

  1. Import the [textcomplete] function from the package.
  2. Define your autocomplete (multiple) strategies.
  3. Define standard streamlit textarea but give it a defined label
  4. Initialize the textcomplete component with this label & your strategies.

Example:

import streamlit as st
from textcomplete import textcomplete, StrategyProps

original_label: str = "Textcomplete Example"
txt: str = st.text_area(
    label=original_label,
    key="st_text_area_1",
)
# Define your autocomplete strategies
username_strategy = StrategyProps(
    id="userFullName",
    match="\\B@(\\w*)$",
    search=async_search_function,  # Define your async search function as JS string
    replace="([fullName]) => `${fullName}`",
    template="([fullName]) => `🧑🏻 ${fullName}`",
)

# Initialize the textcomplete component
textcomplete(
    area_label=original_label,
    strategies=[username_strategy],
    max_count=5,
    # Additional options ...
)

Development

To contribute to the development of Streamlit Textcomplete, you can set up a development environment by cloning the repository and installing the dependencies.

git clone https://github.com/voznik/streamlit-textcomplete.git
cd streamlit-textcomplete
pip install -r requirements.txt

Testing

Run the tests to ensure everything is working as expected:

pytest

License

Streamlit Textcomplete is MIT licensed, as found in the LICENSE file.

Acknowledgments

  • This project is built using the Textcomplete library.
  • Special thanks to the Streamlit community for their support and contributions.

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_textcomplete-0.1.0.tar.gz (157.5 kB view details)

Uploaded Source

Built Distribution

streamlit_textcomplete-0.1.0-py3-none-any.whl (158.7 kB view details)

Uploaded Python 3

File details

Details for the file streamlit_textcomplete-0.1.0.tar.gz.

File metadata

  • Download URL: streamlit_textcomplete-0.1.0.tar.gz
  • Upload date:
  • Size: 157.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.4 Darwin/23.5.0

File hashes

Hashes for streamlit_textcomplete-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fe794c427db0dd28e0bd9ea5aff312e34b22e09b5d08c03784f7067ac62075d6
MD5 6675afc560fbb2c83fad9a1ae65caebf
BLAKE2b-256 c4af0839e194222bf77b5c71207361e36fa70b600c5e0c377676a3c26be43cfe

See more details on using hashes here.

File details

Details for the file streamlit_textcomplete-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for streamlit_textcomplete-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d9b2941b247d4a7c44ae39fc41470cac02080e8dd3c1c668cbe7169a8fcc106f
MD5 67d9ed53aa4031966b1c2100ee1e865a
BLAKE2b-256 860847135dd1054bf8b079226ac765b8e4a7091c3f5fb0ed9d72c2fa2b96b0a3

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