File size: 1,946 Bytes
5b76e0f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Input

A single-line text input widget.

- [x] Focusable
- [ ] Container

## Example

The example below shows how you might create a simple form using two `Input` widgets.

=== "Output"

    ```{.textual path="docs/examples/widgets/input.py" press="tab,D,a,r,r,e,n"}
    ```

=== "input.py"

    ```python
    --8<-- "docs/examples/widgets/input.py"
    ```

## Reactive Attributes

| Name              | Type   | Default | Description                                                     |
| ----------------- | ------ | ------- | --------------------------------------------------------------- |
| `cursor_blink`    | `bool` | `True`  | True if cursor blinking is enabled.                             |
| `value`           | `str`  | `""`    | The value currently in the text input.                          |
| `cursor_position` | `int`  | `0`     | The index of the cursor in the value string.                    |
| `placeholder`     | `str`  | `str`   | The dimmed placeholder text to display when the input is empty. |
| `password`        | `bool` | `False` | True if the input should be masked.                             |

## Messages

### Changed

The `Input.Changed` message is sent when the value in the text input changes.

- [x] Bubbles

#### Attributes

| attribute | type  | purpose                          |
| --------- | ----- | -------------------------------- |
| `value`   | `str` | The new value in the text input. |


### Submitted

The `Input.Submitted` message is sent when you press ++enter++ with the text field submitted.

- [x] Bubbles

#### Attributes

| attribute | type  | purpose                          |
| --------- | ----- | -------------------------------- |
| `value`   | `str` | The new value in the text input. |


## Additional Notes

* The spacing around the text content is due to border. To remove it, set `border: none;` in your CSS.

## See Also

* [Input](../reference/input.md) code reference