| 1 |
--- |
| 2 |
title: Headless tab widgets |
| 3 |
authors: ["@jbuehler23"] |
| 4 |
pull_requests: [25515] |
| 5 |
--- |
| 6 |
|
| 7 |
`bevy_ui_widgets` now has headless tab-strip behavior: a `TabList` container and `Tab` headers, with no built-in visuals. |
| 8 |
|
| 9 |
Selection is externally owned. `SelectedTab` on the list holds the selected tab; interaction emits `ValueChange<Option<Entity>>` as a request, applied by the app or by the optional `tablist_self_update` observer. |
| 10 |
|
| 11 |
Arrow keys move a roving tab index along the list's axis, Home and End jump to the ends, and Enter or Space activates. `TabActivation::Automatic` selects as focus moves; the default `Manual` keeps focus and selection separate. |
| 12 |
|
| 13 |
Tabs derive `Selected`, install tab accessibility roles, and honor `InteractionDisabled` per tab or on the whole list. Only primary-button clicks change selection. |
| 14 |
|
| 15 |
```rust |
| 16 |
( |
| 17 |
TabList::default() |
| 18 |
SelectedTab(Some(first_tab)) |
| 19 |
on(tablist_self_update) |
| 20 |
Children [ |
| 21 |
(Tab Children [Text("General")]), |
| 22 |
(Tab Children [Text("Rendering")]), |
| 23 |
] |
| 24 |
), |
| 25 |
``` |
| 26 |
|
| 27 |
See the `headless_tabs` example for controlled and self-updating tab lists in both orientations. |