Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/better-textbox-docs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"gradio": minor
---

docs: Add "Common Patterns" section to Textbox component docs
35 changes: 35 additions & 0 deletions js/_website/src/lib/templates/gradio/03_components/textbox.svx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,41 @@ gradio.Textbox(···)
### Shortcuts
<ShortcutTable shortcuts={obj.string_shortcuts} />
{/if}
### Common Patterns

#### Multi-line text input

By default, `gr.Textbox` renders as a single-line input. For longer text such as paragraphs or code, set `lines` to show multiple rows and optionally `max_lines` to cap the height:

```python
import gradio as gr

def summarize(text):
return f"Received {len(text.split())} words."

demo = gr.Interface(
fn=summarize,
inputs=gr.Textbox(lines=5, max_lines=10, label="Paste your text here"),
outputs="text",
)
```

#### Password and sensitive input

Set `type="password"` to mask characters as the user types. The value is passed as plain text to your function — masking is display-only:

```python
import gradio as gr

def check(password):
return "Access granted" if password == "secret" else "Wrong password"

demo = gr.Interface(
fn=check,
inputs=gr.Textbox(type="password", label="Enter password"),
outputs="text",
)
```

{#if obj.demos && obj.demos.length > 0}
<!--- Demos -->
Expand Down
Loading