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.
- 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.
To install Streamlit Textcomplete, run the following command in your terminal:
pip install streamlit-textcomplete
To use Streamlit Textcomplete in your Streamlit application, follow these steps:
- Import the [
textcomplete
] function from the package. - Define your autocomplete (multiple) strategies.
- Define standard streamlit textarea but give it a defined label
- 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 ...
)
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
Run the tests to ensure everything is working as expected:
pytest
Streamlit Textcomplete is MIT licensed, as found in the LICENSE file.
- This project is built using the Textcomplete library.
- Special thanks to the Streamlit community for their support and contributions.