You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Tabs: tab list + panels with roles, roving arrow keys, and the panel switch #346
Both consumers build tab strips by hand: b.segmented plus the app's own match to switch the body. So there are no tab/tabpanel roles, no link between a tab and its panel, and no arrow-key movement between tabs.
Proposal: an owned Tabs widget that keeps segmented's look (or a variant) and adds:
role=tablist / tab / tabpanel, with each panel labelled by its tab;
roving focus with ←/→ (Home/End), activation on focus or on Enter (an a11y decision for the user);
the widget owning the body switch, with the selected value in app state.
The docs site also wants it (Rust/HTML code switchers). Design note first; looks go to the user as candidates.
Status: proposal for review. No code yet. Every look question and the API shape are yours to decide; I give a recommendation for each.
Goal (#351): take the "segmented control plus the app's own match" pattern out of the app shells. Add the tab, tab list and tab panel roles, arrow-key movement, and a panel switch the widget owns.
Where it lives: in crates/eggshell-ui-extras, behind a tabs feature, built only on core's public API. Its style lives in extras, and the shadcn values sit behind the shadcn crate's extras feature, as Markdown's do. Core's public API cannot carry it as it stands today. It needs two small public additions, both described in section 3.
1. Proposed public API
use eggshell_ui_extras::tabs::{Activation,TabsExt};#[derive(Clone,Copy,PartialEq)]enumLang{Rust,Html}structApp{lang:Lang}// the selected tab is a plain app fieldfnview<'f>(b:&mutBuilder<'_,'f,App>,app:&'fApp){
b.tabs("lang", app.lang,[(Lang::Rust,"Rust"),(Lang::Html,"HTML")]).named("Language")// the tab list's accessible name.on_change(|app, lang| app.lang = lang).panel(|b, lang| match lang {// builds the selected panel onlyLang::Rust => rust_snippet(b, app),Lang::Html => html_snippet(b, app),});}
The options are anything that implements IntoChoice<T>, the same trait segmented, radio_group and select take. So Choice::new(v, "Label").icon(..).tooltip(..).enablement(..) works unchanged, with no parallel option type.
The other chain methods:
Method
Purpose
.activation(Activation::OnFocus | OnEnter)
Keyboard activation model (see section 2). The default is your choice (Q1).
.size(Size) / .enablement(..)
As on segmented.
.list(Tw) / .panel_classes(Tw)
Classes merged over the styled list and panel, such as w_full().
.on_change(..)
Required, as for segmented. It is not terminal, because the panel still has to be built.
`.panel(
b, value
.strip_only()
Terminal, the alternative to .panel. Use it when the app places the panel itself (Q4).
Who owns state. The selected value is app state: a plain T field the app passes in each frame and sets in on_change. This follows the "app state is plain fields" rule, and the widget never stores the selection. The library stores nothing new either: focus is egui's own, and the single Tab stop is derived each frame from current.
2. Behaviour and keyboard model
Aspect
Proposal
Roles
The list is Role::TabList, named by .named(..). Each tab is Role::Tab with accesskit selected set on the current one. The panel is Role::TabPanel, named by its tab's label (the effect of aria-labelledby), and the tab carries controls → panel id. accesskit 0.25 has all three roles, plus set_controls and set_selected.
Tab stops
The list is one Tab stop: the selected tab, or the first enabled tab when the current value is not among the options. Tab leaves the list for the panel's first focusable item. This is the radio-group rule that eggshell already follows.
Arrows
←/→ move focus to the previous or next enabled tab and wrap, as in Radix (loop defaults to true). Home and End go to the first and last tab. ↑/↓ do nothing in a horizontal list.
Activation
OnFocus (Radix "automatic", the default): moving focus selects, so on_change runs on each arrow press. OnEnter (Radix "manual"): arrows move focus only, and Enter or Space selects. Click selects in both modes. This is an a11y decision for you (Q1).
Panel switch
The widget owns it. .panel builds exactly the selected panel, so the app's match moves into the closure and the widget emits the tabpanel node around it.
Lazy vs kept panels
Lazy only (Radix's default, which unmounts inactive content). Immediate mode makes "kept" pointless: per-node state outlives the frames that don't declare it. eggshell's scroll viewports in Kept are never pruned, and egui keeps text-edit memory by id. So a returning panel finds its scroll offset and its caret. PR 3 asserts this in a test. A "kept but hidden" panel would need a display:none class that core lacks, and I don't propose adding one.
Panel focusability
Radix gives the panel tabindex=0. Q3 asks whether we do.
Disabled tabs
Skipped by the arrows and drawn in the disabled look, as Choice::enablement already documents.
Orientation
Horizontal only in v1. A vertical list (↑/↓) is a variant of the same nav primitive and stays out until a consumer asks (Q5).
3. Reuse, and what core must make public
What the widget reuses:
Options:owned::{Choice, IntoChoice}, which are already public.
Look: segmented's track and cell classes from Style::segmented (SegmentedStyle), so the default tabs look is the segmented look until you choose otherwise. That is exactly what both consumers show today.
Tooltips, enablement, focus ring: the existing public NodeHandle::tooltip, the Enablement look via the classes, and the core focus ring.
accesskit extras:controls and selected go through egui's public Context::accesskit_node_builder in a draw closure, the same pattern core's own NodeHandle::expanded uses.
Why extras cannot build it on today's public API, and the smallest fixes:
Gap
Today
Smallest public core primitive
Roving focus on the page
Nav (Menu, Listbox, Grid) is public, but only overlays and virtual lists accept it. radio_group has a private roving implementation (navigate, take_focus_if_asked, and an egui-temp FOCUS_REQUEST that works around egui dropping focus given to a node that is not yet focusable). Doing it a third time in extras is the forked-implementation hazard.
NodeHandle::nav(Nav) on a page node, plus Nav::Row(Wrap) (←/→, Home, End, real focus; items are nodes with an item role, here Tab and RadioButton), plus NodeHandle::selected(bool), which sets accesskit selectedand marks the group's single Tab stop. radio_group then moves onto it and its private copy is deleted.
The segmented look as classes
Paint::classes and centered are pub(crate), so extras would have to re-derive segmented's class composition. That re-derivation would drift.
SegmentedStyle::track(&self, ctx, size, rows) -> Tw and SegmentedStyle::cell(&self, ctx, size, Cell, Enablement) -> Tw: pure methods that segmented itself calls, so both widgets share one composition.
The widget needs no new #[doc(hidden)] items, no new overlay support and no new clock.
A rejected alternative is a .tabs() mode on segmented that swaps its roles. It is cheaper, but it gives core a shadcn composite, and the panel would still need extras. Rewriting roles in on_response would be a work-around, and the "fix the API" rule rules it out.
4. Look decisions for a render round (no picks made)
I'll render every candidate at real size, in light and dark, next to a panel and a heading:
Variant: the segmented track (shadcn default: bg-muted track, active bg-background shadow-sm), shadcn's line variant (transparent track, 2 px underline under the active tab), or both.
Active tab: fill, shadow, and the dark-mode border-input / bg-input/30 treatment.
Text: inactive colour (shadcn foreground/60, hover → foreground), weight (font-medium), and whether the active tab gets a heavier weight (segmented.selected_weight, which shifts widths).
List width: fit (w-fit) or full width with equal tabs.
Gap between list and panel: shadcn gap-2.
Panel framing: none (shadcn), a card, or a top rule.
Focus ring on a tab, inside the track or overlapping it.
Icon and label spacing and icon size (shadcn gap-1.5, size-4).
Disabled tab look (opacity-50).
Transition of the active fill or underline: none, a cross-fade of fills, or a sliding indicator.
Breaking changes: none. Everything is additive. The radio-group migration in PR 1 is declared behaviour-preserving, and its tests must not change.
PR
Contents
Size
1 (core)
Page-level NodeHandle::nav with Nav::Row(Wrap), NodeHandle::selected, and the single-Tab-stop rule. Moves radio_group onto it and deletes its private roving code. Adds kittest tests through the full dispatch path.
M (~400 lines)
2 (core)
SegmentedStyle::track / cell; segmented calls them. Behaviour-preserving, with goldens unchanged.
S (~120)
3 (extras)
The tabs feature: TabsExt, roles, controls, activation modes, the panel, and tests (roles, arrows, wrap, disabled skip, Tab-stop, state survival across a switch).
M (~450)
4 (extras + shadcn)
Look after the render round: a TabsStyle only if the pick departs from segmented (for example line), its shadcn fill behind extras, and an example for the docs site's Rust/HTML switcher. You try the build before the PR is approved.
S–M
6. Questions for you
#
Question
My recommendation
Q1
Activation: on focus (Radix automatic) or on Enter (manual)? Do we offer both?
Offer both, default OnFocus. It matches Radix and eggshell's radio group, and a panel switch is cheap in immediate mode. OnEnter is for panels that are expensive to build.
Q2
Should Tabs live in extras with the two core primitives (nav on the page with Nav::Row, and the public segmented class methods)? The alternative is a role mode on core's segmented.
Extras plus the two primitives. The roving primitive also deletes radio's private copy.
Q3
Should the panel be a Tab stop (Radix tabindex=0)?
Only when it has no focusable content of its own. In v1 that means no, because both consumers' panels hold controls. Revisit for text-only panels.
Q4
Should the widget always place list and panel together (.panel), or also offer .strip_only() for a list in a toolbar and a panel elsewhere?
Both..strip_only() still sets the roles and needs a panel_id to set controls. Keep it in only if a consumer actually separates the two (one may: its strip sits in a header).
Q5
Vertical orientation in v1?
No.Nav::Column can come later on the same primitive.
Q6
Default look: identical to segmented, or shadcn's tabs (nearly the same), or line?
Render all three. I lean to segmented-identical as the default, so consumers see no visual change on migration.
Look decision revisited (user, 2026-11-19). Every eggshell widget names one shadcn component as its source, with no special cases, so automated extraction applies uniformly.
Tabs follow tabs.tsx exactly:
the list is rounded-lg p-[3px] h-9 on bg-muted;
a trigger is rounded-md px-2 py-1 text-sm font-medium, h-[calc(100%-1px)];
inactive text is foreground/60, with hover:text-foreground;
the active trigger has shadow-sm.
Cited from the pinned ref (styles/style-vega.css:1320-).
Track fill decided (user, 2026-11-19, from the rendered candidates): (b) the input fill for the tabs and segmented track. It's the one documented exception to "exactly tabs.tsx": shadcn's bg-muted vanishes on a muted surface (1.00:1). The other three tabs.tsx values stand. Revisit as an automatic surface-aware rule once the cascade pass (#443) exists. Record the exception, with its reason, in the importer's mapping (#433).
Activity
samitbasu commentedon Nov 18, 2026
Design note: Tabs
Status: proposal for review. No code yet. Every look question and the API shape are yours to decide; I give a recommendation for each.
Goal (#351): take the "segmented control plus the app's own
match" pattern out of the app shells. Add the tab, tab list and tab panel roles, arrow-key movement, and a panel switch the widget owns.Where it lives: in
crates/eggshell-ui-extras, behind atabsfeature, built only on core's public API. Its style lives in extras, and the shadcn values sit behind the shadcn crate'sextrasfeature, as Markdown's do. Core's public API cannot carry it as it stands today. It needs two small public additions, both described in section 3.1. Proposed public API
The options are anything that implements
IntoChoice<T>, the same traitsegmented,radio_groupandselecttake. SoChoice::new(v, "Label").icon(..).tooltip(..).enablement(..)works unchanged, with no parallel option type.The other chain methods:
.activation(Activation::OnFocus | OnEnter).size(Size)/.enablement(..)segmented..list(Tw)/.panel_classes(Tw)w_full()..on_change(..)segmented. It is not terminal, because the panel still has to be built..strip_only().panel. Use it when the app places the panel itself (Q4).Who owns state. The selected value is app state: a plain
Tfield the app passes in each frame and sets inon_change. This follows the "app state is plain fields" rule, and the widget never stores the selection. The library stores nothing new either: focus is egui's own, and the single Tab stop is derived each frame fromcurrent.2. Behaviour and keyboard model
Role::TabList, named by.named(..). Each tab isRole::Tabwith accesskitselectedset on the current one. The panel isRole::TabPanel, named by its tab's label (the effect ofaria-labelledby), and the tab carriescontrols→ panel id. accesskit 0.25 has all three roles, plusset_controlsandset_selected.loopdefaults to true). Home and End go to the first and last tab. ↑/↓ do nothing in a horizontal list.OnFocus(Radix "automatic", the default): moving focus selects, soon_changeruns on each arrow press.OnEnter(Radix "manual"): arrows move focus only, and Enter or Space selects. Click selects in both modes. This is an a11y decision for you (Q1)..panelbuilds exactly the selected panel, so the app'smatchmoves into the closure and the widget emits the tabpanel node around it.Keptare never pruned, and egui keeps text-edit memory by id. So a returning panel finds its scroll offset and its caret. PR 3 asserts this in a test. A "kept but hidden" panel would need adisplay:noneclass that core lacks, and I don't propose adding one.tabindex=0. Q3 asks whether we do.Choice::enablementalready documents.3. Reuse, and what core must make public
What the widget reuses:
owned::{Choice, IntoChoice}, which are already public.Style::segmented(SegmentedStyle), so the default tabs look is the segmented look until you choose otherwise. That is exactly what both consumers show today.NodeHandle::tooltip, theEnablementlook via the classes, and the core focus ring.controlsandselectedgo through egui's publicContext::accesskit_node_builderin a draw closure, the same pattern core's ownNodeHandle::expandeduses.Why extras cannot build it on today's public API, and the smallest fixes:
Nav(Menu, Listbox, Grid) is public, but only overlays and virtual lists accept it.radio_grouphas a private roving implementation (navigate,take_focus_if_asked, and an egui-tempFOCUS_REQUESTthat works around egui dropping focus given to a node that is not yet focusable). Doing it a third time in extras is the forked-implementation hazard.NodeHandle::nav(Nav)on a page node, plusNav::Row(Wrap)(←/→, Home, End, real focus; items are nodes with an item role, hereTabandRadioButton), plusNodeHandle::selected(bool), which sets accesskitselectedand marks the group's single Tab stop.radio_groupthen moves onto it and its private copy is deleted.Paint::classesandcenteredarepub(crate), so extras would have to re-derive segmented's class composition. That re-derivation would drift.SegmentedStyle::track(&self, ctx, size, rows) -> TwandSegmentedStyle::cell(&self, ctx, size, Cell, Enablement) -> Tw: pure methods thatsegmenteditself calls, so both widgets share one composition.The widget needs no new
#[doc(hidden)]items, no new overlay support and no new clock.A rejected alternative is a
.tabs()mode onsegmentedthat swaps its roles. It is cheaper, but it gives core a shadcn composite, and the panel would still need extras. Rewriting roles inon_responsewould be a work-around, and the "fix the API" rule rules it out.4. Look decisions for a render round (no picks made)
I'll render every candidate at real size, in light and dark, next to a panel and a heading:
default:bg-mutedtrack, activebg-background shadow-sm), shadcn'slinevariant (transparent track, 2 px underline under the active tab), or both.border-input/bg-input/30treatment.foreground/60, hover →foreground), weight (font-medium), and whether the active tab gets a heavier weight (segmented.selected_weight, which shifts widths).w-fit) or full width with equal tabs.gap-2.gap-1.5,size-4).opacity-50).Sizescale.5. Breaking changes and PR split
Breaking changes: none. Everything is additive. The radio-group migration in PR 1 is declared behaviour-preserving, and its tests must not change.
NodeHandle::navwithNav::Row(Wrap),NodeHandle::selected, and the single-Tab-stop rule. Movesradio_grouponto it and deletes its private roving code. Adds kittest tests through the full dispatch path.SegmentedStyle::track/cell;segmentedcalls them. Behaviour-preserving, with goldens unchanged.tabsfeature:TabsExt, roles,controls, activation modes, the panel, and tests (roles, arrows, wrap, disabled skip, Tab-stop, state survival across a switch).TabsStyleonly if the pick departs from segmented (for exampleline), its shadcn fill behindextras, and an example for the docs site's Rust/HTML switcher. You try the build before the PR is approved.6. Questions for you
OnFocus. It matches Radix and eggshell's radio group, and a panel switch is cheap in immediate mode.OnEnteris for panels that are expensive to build.navon the page withNav::Row, and the public segmented class methods)? The alternative is a role mode on core'ssegmented.tabindex=0)?.panel), or also offer.strip_only()for a list in a toolbar and a panel elsewhere?.strip_only()still sets the roles and needs apanel_idto setcontrols. Keep it in only if a consumer actually separates the two (one may: its strip sits in a header).Nav::Columncan come later on the same primitive.line?samitbasu commentedon Nov 18, 2026
Decisions (user, 2026-11-18):
.activate_on_enter().Nav::Row(radio_group moves onto it and its private copy is deleted) and segmented's look as public class methods..strip_only()only if a consumer needs it; no vertical tabs in v1.Merge pull request #368 from samitbasu/roving-346
Merge pull request #425 from samitbasu/segclass-346
samitbasu commentedon Nov 20, 2026
Look decision revisited (user, 2026-11-19). Every eggshell widget names one shadcn component as its source, with no special cases, so automated extraction applies uniformly.
tabs.tsxexactly:rounded-lg p-[3px] h-9onbg-muted;rounded-md px-2 py-1 text-sm font-medium,h-[calc(100%-1px)];foreground/60, withhover:text-foreground;shadow-sm.Cited from the pinned ref (
styles/style-vega.css:1320-).tabs.tsx's list look, so tabs and segmented stay identical and now both match shadcn exactly. The 4 differences found in extras: the tabs widget, on core's roving nav and the segmented look (#346, PR 3) #440 are fixed for both, a visible change to segmented, shown in PR 4's render round.samitbasu commentedon Nov 20, 2026
Track fill decided (user, 2026-11-19, from the rendered candidates): (b) the
inputfill for the tabs and segmented track. It's the one documented exception to "exactly tabs.tsx": shadcn'sbg-mutedvanishes on a muted surface (1.00:1). The other three tabs.tsx values stand. Revisit as an automatic surface-aware rule once the cascade pass (#443) exists. Record the exception, with its reason, in the importer's mapping (#433).The segmented look follows shadcn's tabs.tsx; the track keeps input (#…
Merge pull request #440 from samitbasu/tabs-346
Merge pull request #442 from samitbasu/tabs-gallery-346
Merge pull request #386 from samitbasu/accordion-350
Tabs' look from shadcn, for tabs and the segmented control (#446)