# 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](https://textcomplete.streamlit.app/)
![Example Screencast](https://github.com/voznik/streamlit-textcomplete/blob/2277ab7b1589f2dd15b53e564e29b7c2e95191d0/screencast.gif?raw=true)
## 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:
```sh
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:
```python
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.
```sh
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:
```sh
pytest
```
## License
Streamlit Textcomplete is MIT licensed, as found in the [LICENSE](LICENSE) file.
## Acknowledgments
- This project is built using the [Textcomplete](https://yuku.takahashi.coffee/textcomplete/) library.
- Special thanks to the Streamlit community for their support and contributions.
Raw data
{
"_id": null,
"home_page": "https://github.com/voznik/streamlit-textcomplete",
"name": "streamlit-textcomplete",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.10",
"maintainer_email": null,
"keywords": "streamlit, textarea, autocomplete, textcomplete, emoji",
"author": "voznik",
"author_email": "mrvoznik@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/66/89/f5015b0d6745f9845aa17a66cd004976bd3b9a5041869e2ef67a7f5954c1/streamlit_textcomplete-0.2.0.tar.gz",
"platform": null,
"description": "# Streamlit Textcomplete - Autocomplete text in any textarea\n\nStreamlit 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.\n\n## Demo\n\n[demo](https://textcomplete.streamlit.app/)\n\n![Example Screencast](https://github.com/voznik/streamlit-textcomplete/blob/2277ab7b1589f2dd15b53e564e29b7c2e95191d0/screencast.gif?raw=true)\n\n\n## Features\n\n- **Autocomplete for Text Areas**: Enhance textarea in Streamlit with autocomplete functionality, making data input faster and more accurate.\n- **Customizable Strategies**: Define your own strategies for text autocomplete, including username mentions, emoji suggestions, and more.\n- **Easy Integration**: Seamlessly integrates with existing Streamlit applications with minimal setup.\n- **Flexible and Extensible**: Easily extend the component to support additional autocomplete strategies as per your application's needs.\n\n## Installation\n\nTo install Streamlit Textcomplete, run the following command in your terminal:\n\n```sh\npip install streamlit-textcomplete\n```\n\n## Usage\n\nTo use Streamlit Textcomplete in your Streamlit application, follow these steps:\n\n1. Import the [`textcomplete`] function from the package.\n2. Define your autocomplete (multiple) strategies.\n3. Define standard streamlit textarea but give it a defined label\n4. Initialize the textcomplete component with this label & your strategies.\n\nExample:\n\n```python\nimport streamlit as st\nfrom textcomplete import textcomplete, StrategyProps\n\noriginal_label: str = \"Textcomplete Example\"\ntxt: str = st.text_area(\n label=original_label,\n key=\"st_text_area_1\",\n)\n# Define your autocomplete strategies\nusername_strategy = StrategyProps(\n id=\"userFullName\",\n match=\"\\\\B@(\\\\w*)$\",\n search=async_search_function, # Define your async search function as JS string\n replace=\"([fullName]) => `${fullName}`\",\n template=\"([fullName]) => `\ud83e\uddd1\ud83c\udffb ${fullName}`\",\n)\n\n# Initialize the textcomplete component\ntextcomplete(\n area_label=original_label,\n strategies=[username_strategy],\n max_count=5,\n # Additional options ...\n)\n```\n\n## Development\n\nTo contribute to the development of Streamlit Textcomplete, you can set up a development environment by cloning the repository and installing the dependencies.\n\n```sh\ngit clone https://github.com/voznik/streamlit-textcomplete.git\ncd streamlit-textcomplete\npip install -r requirements.txt\n```\n\n## Testing\n\nRun the tests to ensure everything is working as expected:\n\n```sh\npytest\n```\n\n## License\n\nStreamlit Textcomplete is MIT licensed, as found in the [LICENSE](LICENSE) file.\n\n## Acknowledgments\n\n- This project is built using the [Textcomplete](https://yuku.takahashi.coffee/textcomplete/) library.\n- Special thanks to the Streamlit community for their support and contributions.\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Streamlit autocomplete Textcomplete editor for HTMLTextAreaElement",
"version": "0.2.0",
"project_urls": {
"Homepage": "https://github.com/voznik/streamlit-textcomplete",
"Repository": "https://github.com/voznik/streamlit-textcomplete"
},
"split_keywords": [
"streamlit",
" textarea",
" autocomplete",
" textcomplete",
" emoji"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "bc5f7110b2fa578afa4ab937777e1861bc3fc03811834f75b90704604f08e2a4",
"md5": "f2a14386d7d97faed0776a21be8ef100",
"sha256": "d18df56a61776b36345538dcdfbad1a8878a5590a5f1af604f3de3f4835ca4e3"
},
"downloads": -1,
"filename": "streamlit_textcomplete-0.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "f2a14386d7d97faed0776a21be8ef100",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.10",
"size": 129962,
"upload_time": "2024-10-16T20:11:28",
"upload_time_iso_8601": "2024-10-16T20:11:28.580645Z",
"url": "https://files.pythonhosted.org/packages/bc/5f/7110b2fa578afa4ab937777e1861bc3fc03811834f75b90704604f08e2a4/streamlit_textcomplete-0.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "6689f5015b0d6745f9845aa17a66cd004976bd3b9a5041869e2ef67a7f5954c1",
"md5": "b9959d8336fb3c201be716fd57f89781",
"sha256": "861b93de5fba2e35b569a68201347bdaf4839034e488ab1ad85a91c7d134ebba"
},
"downloads": -1,
"filename": "streamlit_textcomplete-0.2.0.tar.gz",
"has_sig": false,
"md5_digest": "b9959d8336fb3c201be716fd57f89781",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.10",
"size": 124859,
"upload_time": "2024-10-16T20:11:30",
"upload_time_iso_8601": "2024-10-16T20:11:30.213570Z",
"url": "https://files.pythonhosted.org/packages/66/89/f5015b0d6745f9845aa17a66cd004976bd3b9a5041869e2ef67a7f5954c1/streamlit_textcomplete-0.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-16 20:11:30",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "voznik",
"github_project": "streamlit-textcomplete",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "streamlit-textcomplete"
}