> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/gradio-app/gradio/llms.txt
> Use this file to discover all available pages before exploring further.

# Textbox

> Create text input and output components in Gradio

The Textbox component creates a text input field for users to enter strings or display string output.

## Basic usage

```python theme={null}
import gradio as gr

def echo(text):
    return text

gr.Interface(fn=echo, inputs=gr.Textbox(), outputs=gr.Textbox()).launch()
```

## Constructor

<ParamField path="value" type="str | Callable | None" default="None">
  Default text to display. If a function is provided, it will be called each time the app loads
</ParamField>

<ParamField path="type" type="Literal['text', 'password', 'email']" default="'text'">
  Input type:

  * `"text"` - Standard text input
  * `"password"` - Masked password input
  * `"email"` - Email input with validation

  For "password" and "email", `lines` must be 1
</ParamField>

<ParamField path="lines" type="int" default="1">
  Minimum number of visible lines
</ParamField>

<ParamField path="max_lines" type="int | None" default="None">
  Maximum number of visible lines. If None, defaults to `max(lines, 20)` for text type
</ParamField>

<ParamField path="placeholder" type="str | None" default="None">
  Placeholder hint text
</ParamField>

<ParamField path="label" type="str | None" default="None">
  Label displayed above the component
</ParamField>

<ParamField path="info" type="str | None" default="None">
  Additional info text below the label. Supports markdown/HTML
</ParamField>

<ParamField path="show_label" type="bool | None" default="None">
  Whether to display the label
</ParamField>

<ParamField path="interactive" type="bool | None" default="None">
  Whether the textbox is editable. Inferred automatically if not provided
</ParamField>

<ParamField path="visible" type="bool | Literal['hidden']" default="True">
  Whether the component is visible
</ParamField>

<ParamField path="autofocus" type="bool" default="False">
  Whether to focus on the textbox when the page loads
</ParamField>

<ParamField path="autoscroll" type="bool" default="True">
  Whether to automatically scroll to bottom when value changes
</ParamField>

<ParamField path="text_align" type="Literal['left', 'right'] | None" default="None">
  Text alignment. Only works with `type="text"`
</ParamField>

<ParamField path="rtl" type="bool" default="False">
  Whether to render text right-to-left. Only works with `type="text"`
</ParamField>

<ParamField path="max_length" type="int | None" default="None">
  Maximum character length (including newlines)
</ParamField>

<ParamField path="submit_btn" type="str | bool | None" default="False">
  * `True` - Show submit button with icon
  * `str` - Show submit button with custom text
  * `False` - Hide submit button
</ParamField>

<ParamField path="stop_btn" type="str | bool | None" default="False">
  * `True` - Show stop button with icon
  * `str` - Show stop button with custom text
  * `False` - Hide stop button
</ParamField>

<ParamField path="buttons" type="list[Literal['copy'] | Button] | None" default="None">
  List of buttons to show. Options:

  * `"copy"` - Copy text to clipboard
  * Custom `gr.Button()` instances
</ParamField>

## Events

The Textbox component supports the following events:

* **change** - Triggered when value changes
* **input** - Triggered on every keystroke
* **select** - Triggered when text is selected
* **submit** - Triggered when Enter is pressed
* **focus** - Triggered when component gains focus
* **blur** - Triggered when component loses focus
* **stop** - Triggered when stop button is clicked
* **copy** - Triggered when text is copied

### Example with events

```python theme={null}
import gradio as gr

def handle_change(text):
    return f"You typed: {text}"

with gr.Blocks() as demo:
    textbox = gr.Textbox(label="Enter text")
    output = gr.Textbox(label="Output", interactive=False)
    
    textbox.change(fn=handle_change, inputs=textbox, outputs=output)
    
demo.launch()
```

## Advanced features

### Password input

```python theme={null}
import gradio as gr

def verify_password(password):
    return "✓ Password accepted" if len(password) >= 8 else "✗ Too short"

gr.Interface(
    fn=verify_password,
    inputs=gr.Textbox(type="password", label="Password"),
    outputs=gr.Textbox(label="Status")
).launch()
```

### Multiline text

```python theme={null}
import gradio as gr

textbox = gr.Textbox(
    lines=5,
    max_lines=10,
    placeholder="Enter multiple lines...",
    label="Long text input"
)
```

### Chat-style interface

```python theme={null}
import gradio as gr

with gr.Blocks() as demo:
    chatbox = gr.Textbox(
        placeholder="Type a message...",
        submit_btn="Send",
        stop_btn="Stop"
    )
    
demo.launch()
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.