---
tags: [gradio-custom-component, SimpleTextbox, text, textbox, autocomplete, highlight, textarea]
title: gradio_autocompletetextbox
short_description: A textbox that supports autocomplete suggestions defined during initialization
colorFrom: blue
colorTo: yellow
sdk: gradio
pinned: false
app_file: space.py
---
# `gradio_autocompletetextbox`
<img alt="Static Badge" src="https://img.shields.io/badge/version%20-%200.0.1%20-%20orange">
A textbox that supports autocomplete suggestions defined during initialization
## Installation
```bash
pip install gradio_autocompletetextbox
```
## Usage
```python
import gradio as gr
from matplotlib import container
from gradio_autocompletetextbox import AutocompleteTextbox
from numpy import place
with gr.Blocks() as demo:
gr.Markdown("## AutocompleteTextbox")
with gr.Row():
with gr.Column():
code = gr.Code()
with gr.Column(elem_classes=["col_container"]):
chatbot = gr.Chatbot(bubble_full_width=False, container=False)
input_text = AutocompleteTextbox(
show_label=False,
commands=["/start", "/stop", "/help", "/info"],
placeholder="Type a command...",
interactive=True,
container=False,
)
clear = gr.Button("Clear")
ref = gr.Text(container=False, placeholder="Type a command...")
if __name__ == "__main__":
demo.launch()
```
## `AutocompleteTextbox`
### Initialization
<table>
<thead>
<tr>
<th align="left">name</th>
<th align="left" style="width: 25%;">type</th>
<th align="left">default</th>
<th align="left">description</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left"><code>value</code></td>
<td align="left" style="width: 25%;">
```python
CommandData | Callable | None
```
</td>
<td align="left"><code>None</code></td>
<td align="left">default text to provide in textbox. If callable, the function will be called whenever the app loads to set the initial value of the component.</td>
</tr>
<tr>
<td align="left"><code>commands</code></td>
<td align="left" style="width: 25%;">
```python
list[str] | None
```
</td>
<td align="left"><code>None</code></td>
<td align="left">None</td>
</tr>
<tr>
<td align="left"><code>placeholder</code></td>
<td align="left" style="width: 25%;">
```python
str | None
```
</td>
<td align="left"><code>None</code></td>
<td align="left">placeholder hint to provide behind textbox.</td>
</tr>
<tr>
<td align="left"><code>label</code></td>
<td align="left" style="width: 25%;">
```python
str | None
```
</td>
<td align="left"><code>None</code></td>
<td align="left">component name in interface.</td>
</tr>
<tr>
<td align="left"><code>container</code></td>
<td align="left" style="width: 25%;">
```python
bool
```
</td>
<td align="left"><code>True</code></td>
<td align="left">None</td>
</tr>
<tr>
<td align="left"><code>every</code></td>
<td align="left" style="width: 25%;">
```python
Timer | float | None
```
</td>
<td align="left"><code>None</code></td>
<td align="left">Continously calls `value` to recalculate it if `value` is a function (has no effect otherwise). Can provide a Timer whose tick resets `value`, or a float that provides the regular interval for the reset Timer.</td>
</tr>
<tr>
<td align="left"><code>inputs</code></td>
<td align="left" style="width: 25%;">
```python
Component | Sequence[Component] | set[Component] | None
```
</td>
<td align="left"><code>None</code></td>
<td align="left">Components that are used as inputs to calculate `value` if `value` is a function (has no effect otherwise). `value` is recalculated any time the inputs change.</td>
</tr>
<tr>
<td align="left"><code>show_label</code></td>
<td align="left" style="width: 25%;">
```python
bool | None
```
</td>
<td align="left"><code>None</code></td>
<td align="left">if True, will display label.</td>
</tr>
<tr>
<td align="left"><code>scale</code></td>
<td align="left" style="width: 25%;">
```python
int | None
```
</td>
<td align="left"><code>None</code></td>
<td align="left">relative size compared to adjacent Components. For example if Components A and B are in a Row, and A has scale=2, and B has scale=1, A will be twice as wide as B. Should be an integer. scale applies in Rows, and to top-level Components in Blocks where fill_height=True.</td>
</tr>
<tr>
<td align="left"><code>min_width</code></td>
<td align="left" style="width: 25%;">
```python
int
```
</td>
<td align="left"><code>160</code></td>
<td align="left">minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first.</td>
</tr>
<tr>
<td align="left"><code>interactive</code></td>
<td align="left" style="width: 25%;">
```python
bool | None
```
</td>
<td align="left"><code>None</code></td>
<td align="left">if True, will be rendered as an editable textbox; if False, editing will be disabled. If not provided, this is inferred based on whether the component is used as an input or output.</td>
</tr>
<tr>
<td align="left"><code>visible</code></td>
<td align="left" style="width: 25%;">
```python
bool
```
</td>
<td align="left"><code>True</code></td>
<td align="left">If False, component will be hidden.</td>
</tr>
<tr>
<td align="left"><code>rtl</code></td>
<td align="left" style="width: 25%;">
```python
bool
```
</td>
<td align="left"><code>False</code></td>
<td align="left">If True and `type` is "text", sets the direction of the text to right-to-left (cursor appears on the left of the text). Default is False, which renders cursor on the right.</td>
</tr>
<tr>
<td align="left"><code>elem_id</code></td>
<td align="left" style="width: 25%;">
```python
str | None
```
</td>
<td align="left"><code>None</code></td>
<td align="left">An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.</td>
</tr>
<tr>
<td align="left"><code>elem_classes</code></td>
<td align="left" style="width: 25%;">
```python
list[str] | str | None
```
</td>
<td align="left"><code>None</code></td>
<td align="left">An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.</td>
</tr>
<tr>
<td align="left"><code>render</code></td>
<td align="left" style="width: 25%;">
```python
bool
```
</td>
<td align="left"><code>True</code></td>
<td align="left">If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.</td>
</tr>
<tr>
<td align="left"><code>key</code></td>
<td align="left" style="width: 25%;">
```python
int | str | None
```
</td>
<td align="left"><code>None</code></td>
<td align="left">if assigned, will be used to assume identity across a re-render. Components that have the same key across a re-render will have their value preserved.</td>
</tr>
</tbody></table>
### Events
| name | description |
|:-----|:------------|
| `change` | Triggered when the value of the AutocompleteTextbox changes either because of user input (e.g. a user types in a textbox) OR because of a function update (e.g. an image receives a value from the output of an event trigger). See `.input()` for a listener that is only triggered by user input. |
| `input` | This listener is triggered when the user changes the value of the AutocompleteTextbox. |
| `submit` | This listener is triggered when the user presses the Enter key while the AutocompleteTextbox is focused. |
### User function
The impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both).
- When used as an Input, the component only impacts the input signature of the user function.
- When used as an output, the component only impacts the return signature of the user function.
The code snippet below is accurate in cases where the component is used as both an input and an output.
- **As output:** Is passed, passes text value as a {str} into the function.
- **As input:** Should return, expects a {str} returned from function and sets textarea value to it.
```python
def predict(
value: dict
) -> str | CommandData | dict | None:
return value
```
## `CommandData`
```python
class CommandData(GradioModel):
command: str | None = None
text: str = ""
```
Raw data
{
"_id": null,
"home_page": null,
"name": "gradio-autocompletetextbox",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "autocomplete, gradio-custom-component, gradio-template-SimpleTextbox, highlight, text, textarea, textbox",
"author": null,
"author_email": "YOUR NAME <YOUREMAIL@domain.com>",
"download_url": "https://files.pythonhosted.org/packages/af/d0/a864192648379421ae63c5e2100bc466be2cacbf088f5a8507d00042328f/gradio_autocompletetextbox-0.0.2.tar.gz",
"platform": null,
"description": "---\ntags: [gradio-custom-component, SimpleTextbox, text, textbox, autocomplete, highlight, textarea]\ntitle: gradio_autocompletetextbox\nshort_description: A textbox that supports autocomplete suggestions defined during initialization\ncolorFrom: blue\ncolorTo: yellow\nsdk: gradio\npinned: false\napp_file: space.py\n---\n\n# `gradio_autocompletetextbox`\n<img alt=\"Static Badge\" src=\"https://img.shields.io/badge/version%20-%200.0.1%20-%20orange\"> \n\nA textbox that supports autocomplete suggestions defined during initialization\n\n## Installation\n\n```bash\npip install gradio_autocompletetextbox\n```\n\n## Usage\n\n```python\n\nimport gradio as gr\nfrom matplotlib import container\nfrom gradio_autocompletetextbox import AutocompleteTextbox\nfrom numpy import place\n\n\nwith gr.Blocks() as demo:\n gr.Markdown(\"## AutocompleteTextbox\")\n\n with gr.Row():\n with gr.Column():\n code = gr.Code()\n with gr.Column(elem_classes=[\"col_container\"]):\n chatbot = gr.Chatbot(bubble_full_width=False, container=False)\n \n input_text = AutocompleteTextbox(\n show_label=False,\n commands=[\"/start\", \"/stop\", \"/help\", \"/info\"],\n placeholder=\"Type a command...\", \n interactive=True, \n container=False,\n )\n \n clear = gr.Button(\"Clear\")\n \n ref = gr.Text(container=False, placeholder=\"Type a command...\")\n\nif __name__ == \"__main__\":\n demo.launch()\n\n```\n\n## `AutocompleteTextbox`\n\n### Initialization\n\n<table>\n<thead>\n<tr>\n<th align=\"left\">name</th>\n<th align=\"left\" style=\"width: 25%;\">type</th>\n<th align=\"left\">default</th>\n<th align=\"left\">description</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td align=\"left\"><code>value</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nCommandData | Callable | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">default text to provide in textbox. If callable, the function will be called whenever the app loads to set the initial value of the component.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>commands</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nlist[str] | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">None</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>placeholder</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nstr | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">placeholder hint to provide behind textbox.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>label</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nstr | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">component name in interface.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>container</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nbool\n```\n\n</td>\n<td align=\"left\"><code>True</code></td>\n<td align=\"left\">None</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>every</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nTimer | float | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">Continously calls `value` to recalculate it if `value` is a function (has no effect otherwise). Can provide a Timer whose tick resets `value`, or a float that provides the regular interval for the reset Timer.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>inputs</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nComponent | Sequence[Component] | set[Component] | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">Components that are used as inputs to calculate `value` if `value` is a function (has no effect otherwise). `value` is recalculated any time the inputs change.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>show_label</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nbool | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">if True, will display label.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>scale</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nint | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">relative size compared to adjacent Components. For example if Components A and B are in a Row, and A has scale=2, and B has scale=1, A will be twice as wide as B. Should be an integer. scale applies in Rows, and to top-level Components in Blocks where fill_height=True.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>min_width</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nint\n```\n\n</td>\n<td align=\"left\"><code>160</code></td>\n<td align=\"left\">minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>interactive</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nbool | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">if True, will be rendered as an editable textbox; if False, editing will be disabled. If not provided, this is inferred based on whether the component is used as an input or output.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>visible</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nbool\n```\n\n</td>\n<td align=\"left\"><code>True</code></td>\n<td align=\"left\">If False, component will be hidden.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>rtl</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nbool\n```\n\n</td>\n<td align=\"left\"><code>False</code></td>\n<td align=\"left\">If True and `type` is \"text\", sets the direction of the text to right-to-left (cursor appears on the left of the text). Default is False, which renders cursor on the right.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>elem_id</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nstr | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>elem_classes</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nlist[str] | str | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>render</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nbool\n```\n\n</td>\n<td align=\"left\"><code>True</code></td>\n<td align=\"left\">If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>key</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nint | str | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">if assigned, will be used to assume identity across a re-render. Components that have the same key across a re-render will have their value preserved.</td>\n</tr>\n</tbody></table>\n\n\n### Events\n\n| name | description |\n|:-----|:------------|\n| `change` | Triggered when the value of the AutocompleteTextbox changes either because of user input (e.g. a user types in a textbox) OR because of a function update (e.g. an image receives a value from the output of an event trigger). See `.input()` for a listener that is only triggered by user input. |\n| `input` | This listener is triggered when the user changes the value of the AutocompleteTextbox. |\n| `submit` | This listener is triggered when the user presses the Enter key while the AutocompleteTextbox is focused. |\n\n\n\n### User function\n\nThe impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both).\n\n- When used as an Input, the component only impacts the input signature of the user function.\n- When used as an output, the component only impacts the return signature of the user function.\n\nThe code snippet below is accurate in cases where the component is used as both an input and an output.\n\n- **As output:** Is passed, passes text value as a {str} into the function.\n- **As input:** Should return, expects a {str} returned from function and sets textarea value to it.\n\n ```python\n def predict(\n value: dict\n ) -> str | CommandData | dict | None:\n return value\n ```\n \n\n## `CommandData`\n```python\nclass CommandData(GradioModel):\n command: str | None = None\n text: str = \"\"\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "A textbox that supports autocomplete suggestions defined during initialization",
"version": "0.0.2",
"project_urls": null,
"split_keywords": [
"autocomplete",
" gradio-custom-component",
" gradio-template-simpletextbox",
" highlight",
" text",
" textarea",
" textbox"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "deb1ebf8aadd6cf937c265b660bbdf5edcb1b1be913f0eb767352e56eec99843",
"md5": "ab51c5f5345da953122c4a34b36a2334",
"sha256": "2f786071874de719e9023db0152b89bbec74b811c4800457838d26437693516f"
},
"downloads": -1,
"filename": "gradio_autocompletetextbox-0.0.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ab51c5f5345da953122c4a34b36a2334",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 45217,
"upload_time": "2024-08-09T20:46:32",
"upload_time_iso_8601": "2024-08-09T20:46:32.098910Z",
"url": "https://files.pythonhosted.org/packages/de/b1/ebf8aadd6cf937c265b660bbdf5edcb1b1be913f0eb767352e56eec99843/gradio_autocompletetextbox-0.0.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "afd0a864192648379421ae63c5e2100bc466be2cacbf088f5a8507d00042328f",
"md5": "e6f4f0562580d3d56e957b25bfd2f6e6",
"sha256": "e6305b15717c308eecb7c5e6b7f9345326b3407c5f7de113cee84dd81179361d"
},
"downloads": -1,
"filename": "gradio_autocompletetextbox-0.0.2.tar.gz",
"has_sig": false,
"md5_digest": "e6f4f0562580d3d56e957b25bfd2f6e6",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 89649,
"upload_time": "2024-08-09T20:46:34",
"upload_time_iso_8601": "2024-08-09T20:46:34.373595Z",
"url": "https://files.pythonhosted.org/packages/af/d0/a864192648379421ae63c5e2100bc466be2cacbf088f5a8507d00042328f/gradio_autocompletetextbox-0.0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-09 20:46:34",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "gradio-autocompletetextbox"
}