Skip to content

Tabs example, and the segmented look follows shadcn's tabs.tsx (#346, PR 4) - #442

Merged
samitbasu merged 8 commits into
mainfrom
tabs-gallery-346
Nov 20, 2026
Merged

samitbasu merged 8 commits into
mainfrom
tabs-gallery-346

Conversation

@samitbasu

@samitbasu samitbasu commented Nov 20, 2026 •

Copy link
Copy Markdown
Owner

Part of #346: PR 4 of the design note, the tabs example and the trial. Stacked on #440 (PR 3, tabs-346), so its diff shows the example alone.

What

examples/tabs.rs, run with cargo xtask example tabs or served on the web:

  • shadcn/ui's tabs demo: an Account form and a Password form, each a card with its fields and a button;
  • a code switcher (Rust, HTML, CSS), as on a docs page;
  • tabs with icons (Light, Dark, System), with System refused and its reason as the tooltip;
  • tabs that select on Enter or Space (activate_on_enter), with a disabled third tab.

For you to try

Keyboard:

  • Tab into a list: it's one stop, on the selected tab.
  • ←/→ move along it and wrap. Home and End go to the ends.
  • Tab again goes on into the panel.
  • In the first three lists, the arrows select as they move.
  • In the last list ("Enter or Space selects"), the arrows only move the focus, and Enter or Space selects.

Panels:

  • Only the selected panel is built.
  • Type in the Account form, switch to Password and back: the fields hold the app's state, and the panel's own state comes back with it.

Disabled:

  • System and Exports are skipped by the arrows and take no click.
  • System shows its reason on hover.

Screen reader: the list, the tabs and the panel read as a tab list, tabs and a tab panel. The panel is named by its tab.

The look: tabs.tsx, for tabs and the segmented control alike

Decided by the user: every widget names one shadcn source. Tabs follow tabs.tsx, and the segmented control's source is tabs.tsx's list look too, so the two stay identical and both change here. Each value is cited at the line that sets it in crates/eggshell-ui-shadcn/src/preset.rs.

  • Inactive text: light is foreground at 60% (text-foreground/60); dark keeps muted-foreground (dark:text-muted-foreground).
  • Hover: an inactive cell's text turns foreground under the pointer (hover:text-foreground).
  • Cell height:
    • A cell is 1 pt shorter than the track's inside, centred (h-[calc(100%-1px)]).
    • It's expressed as a new core metric, SegmentedMetrics::cell_trim, which the track takes as half a point more vertical padding each side, so a caller's own track height still holds. 0, core's default, keeps today's look.
    • In the preset the point comes out of the cell's vertical padding (4 → 3.5). 29 pt can't hold py-1, a 20 pt text-sm line and the border: shadcn's own trigger overflows by 1 px there, which the browser hides and the overflow check here doesn't.
  • The one exception: the track keeps input, not bg-muted.

Goldens: 54 of 199 move, all for these changes. They're reviewed as a before/after sheet: https://claude.ai/artifact/YUU7rbNrLZdZjV7YowchQh

  • 42 show a segmented control: controls_gallery (default, wide, narrow, dark, buttons, choices, labels, values, select_open, stepper_focused, light and dark), control_sizes, form, form_sections, chat_shell (light, dark, composer_grown, composer_scrolling), dnd_gallery_drag_chip, and lyra's form, chat_shell and controls_gallery.
  • 12 change only through the examples' theme bar, whose light/dark switch is a segmented control: icons, icons_menu, flexbox_guide ×2, flex_demos ×2, port_flex_wrap and typeset ×3.

Tests:

  • The two tests that pinned the cell 3 pt from the track now pin 3.5 pt and 29 pt (owned_choice::segmented_track_and_cells_are_the_styles, style::the_shadcn_segmented_style_raises_exactly_the_selected_cell).
  • tests/it/support::same, which finds a drawn rect, now allows each edge the half point drawing rounds by. Before, it measured the corner distance as a whole vector, and that failed on a cell at a half point.

Breaking changes

SegmentedMetrics gains cell_trim. The struct isn't #[non_exhaustive], so a struct literal of it needs the field. 0 keeps today's look.

Checks

  • The example builds with clippy clean.
  • I rendered it in both themes (lavapipe), and it reads as intended.
  • cargo test --workspace passes, and clippy is clean.
  • The goldens are regenerated once, after the user's pick, as listed above.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LesfK54UWq1haPSEr9X22o

samitbasu and others added 3 commits November 19, 2026 16:06
The account and password forms of shadcn's demo, a code switcher, tabs
with icons and a refused tab, and tabs that select on Enter. The trial
build for the tabs widget.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LesfK54UWq1haPSEr9X22o
…ser's pick)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LesfK54UWq1haPSEr9X22o
…346)

Tabs draw in the segmented control's look, and the user decided both
follow tabs.tsx exactly, with one exception:
- an inactive cell's text is foreground at 60% in light
  (`text-foreground/60`), muted-foreground in dark, and foreground under
  the pointer (`hover:text-foreground`);
- a cell is 1 pt shorter than the track's inside, centred
  (`h-[calc(100%-1px)]`): SegmentedMetrics::cell_trim, given to the
  track as half a point more vertical padding each side, so a caller's
  own track height still holds; the preset's cells take the point out of
  their vertical padding (3.5), since 29 pt cannot hold py-1, a 20 pt
  line and the border without overflowing;
- the track keeps `input`, not tabs.tsx's `bg-muted`: on a muted panel
  that fill is the panel's own and the track disappears (the user's pick;
  revisit with the cascade, #443).

Breaking: SegmentedMetrics gains `cell_trim` (0 keeps today's look), so
a struct literal of it needs the field.

54 goldens move, reviewed as a before/after sheet; the two tests that
pinned the cell 3 pt from the track pin 3.5 and 29 pt, and
support::same matches a drawn rect per edge within the half point
drawing rounds by.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LesfK54UWq1haPSEr9X22o
@samitbasu samitbasu changed the title examples: tabs, after shadcn/ui's tabs demo (#346, PR 4) Tabs example, and the segmented look follows shadcn's tabs.tsx (#346, PR 4) Nov 20, 2026
@samitbasu
samitbasu changed the base branch from tabs-346 to main November 20, 2026 01:49
@samitbasu

Copy link
Copy Markdown
Owner Author

Approved by the user after the Tabs trial (2026-11-19); the segmented look follows shadcn's tabs.tsx, with the input track fill. GitHub's required checks pass on the branch merged with current main. Merging.

@samitbasu
samitbasu merged commit ea3f635 into main Nov 20, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant