mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
As pointed out in #1649, a `ChildrenUpdated` message is documented but it doesn't exist in the code. It looks like it got added during development, then removed after it was realised it wasn't needed, but presumably it got left in the docs: https://github.com/Textualize/textual/pull/1143#discussion_r1030409026
1.5 KiB
1.5 KiB
List View
Displays a vertical list of ListItems which can be highlighted and selected.
Supports keyboard navigation.
- Focusable
- Container
Example
The example below shows an app with a simple ListView.
=== "Output"
```{.textual path="docs/examples/widgets/list_view.py"}
```
=== "list_view.py"
```python
--8<-- "docs/examples/widgets/list_view.py"
```
=== "list_view.css"
```sass
--8<-- "docs/examples/widgets/list_view.css"
```
Reactive Attributes
| Name | Type | Default | Description |
|---|---|---|---|
index |
int |
0 |
The currently highlighted index |
Messages
Highlighted
The ListView.Highlighted message is emitted when the highlight changes.
This happens when you use the arrow keys on your keyboard and when you
click on a list item.
- Bubbles
Attributes
| attribute | type | purpose |
|---|---|---|
item |
ListItem |
The item that was highlighted. |
Selected
The ListView.Selected message is emitted when a list item is selected.
You can select a list item by pressing ++enter++ while it is highlighted,
or by clicking on it.
- Bubbles
Attributes
| attribute | type | purpose |
|---|---|---|
item |
ListItem |
The item that was selected. |
See Also
- ListView code reference