Tabs (legacy)
Tabs is the Rust crate's older tab container: a .hk-tabs box whose .hk-tabs-nav holds the triggers and an ink bar, and whose .hk-tabs-content holds the panels. TabPane is the child that provides one trigger and one panel. This page documents a legacy migration surface — it keeps existing Rust pages building; new surfaces should use the Vue strip, HkTabs.
TabPane has no page of its own: it is documented here, with the container that drives it.
- The shared name is the trap. HkTabs and its Rust mirror SegmentedTabs are the current pair (tablist / tabpanel semantics, a sliding pill indicator, arrow-key navigation). This Tabs is an unrelated, older Rust component, and nothing in Vue mirrors it: there is no HkTabs variant that renders this shape.
- The declared-but-empty TabPosition variants (Right / Bottom / Left) only change a class name, and on_change is never called — the surface is a static container, not a working switch. Read the second and third sections before you rely on either.
- Reach for it while migrating a Rust page that already renders this shape; the new pair is HkTabs on the Vue side, whose Rust mirror SegmentedTabs covers the segmented variant only.
Import
use *; // Tabs, TabPane, TabPosition
use *; // TabsProps, TabPaneProps, rsx!, VNode
Both are plain functions, Tabs(TabsProps { … }) and TabPane(TabPaneProps { … }). TabsProps and TabPaneProps are in the prelude; TabPosition is not. Inside rsx! every prop may be omitted: default_active defaults to "", tab_position to TabPosition::Top, animated to true, and class / children to the empty string / the empty vnode. The two element slots are required in practice — Tabs has no #[default] on children, so give it a rsx! child block, written bare (children: rsx! { … }), not wrapped in Some(…).
Rust examples of this component cannot pass the docs gate. Tabs renders props.children twice (once inside .hk-tabs-nav-list, once inside .hk-tabs-content), and each TabPane reads its active flag from a context that Tabs provides. A fence is wrapped in one component body followed by a single render_to_html(), and the second traversal of the same pane panics:
thread 'main' panicked at packages/components/src/navigation/tabs.rs:129:54:
TabsContext not found
The :129:54 in that report is rustc's own output: the column points at the start of the expect( call, not at the message string.
The panic reproduces with the container as the only node in the fence, with the <Signal<String>> context seeded by hand, and in a hand-written main — only splitting the children between the two traversals avoids it, and a fence cannot do that. This page therefore carries no fence for the legacy component: the call shape and the produced markup are described in prose and inline code below.
What the container renders
Tabs writes one class list on the root — hk-tabs, the position class (hk-tabs-top / hk-tabs-right / hk-tabs-bottom / hk-tabs-left), hk-tabs-animated when animated is true, then class — and nothing else derives from the props.
Inside it are two children in a fixed order:
- .hk-tabs-nav holds .hk-tabs-nav-list[role="tablist"], whose children are props.children again, and .hk-tabs-ink-bar. The ink bar carries a literal transform: translateX(...) — the placeholder string is passed through unchanged, so it does not place anything; there is no measurement pass in Rust.
- .hk-tabs-content carries role="tabpanel" and props.children once more.
Because the content region is the same children list as the nav, a Tabs whose panes are TabPanes has every pane's trigger pair and every pane's body in both regions. There is no per-pane visibility rule inside the container: the only thing that decides a pane's open state is TabPane's own aria-hidden / active class, and the content region renders whatever children produced. Layout the two regions yourself if you need exactly one panel visible.
TabPane, and the context it needs
TabPane is not self-sufficient. It calls use_context::<Signal<String>>() and panics when nothing provided it:
thread 'main' panicked at packages/components/src/navigation/tabs.rs:129:54:
TabsContext not found
Only Tabs provides that context, and only while Tabs itself is rendering — so the intended call shape is a TabPane as a direct child of a rendering Tabs, never a TabPane on its own and never a TabPane evaluated before the container's own render. Tabs seeds the signal from default_active and never writes it again, so the active pane is a mount-time constant: there is no way to change the visible tab from the outside, and no event reports a change.
A pane renders two nodes into one fragment:
- a div.hk-tabs-tab[role="tab"] with data-key = item_key, aria-selected = active, aria-disabled = disabled, the hk-tab-active / hk-tab-disabled classes as appropriate, an optional span.hk-tabs-tab-icon around icon, and a span.hk-tabs-tab-label holding tab;
- a div.hk-tabs-tabpane[role="tabpanel"] with data-key, aria-hidden = "true" when it is not active, the hk-tabpane-active / hk-tabpane-inactive class, and its children rendered only while active (an inactive pane's body is the empty vnode inside the element).
item_key is compared to the container's default_active as a plain string — it is also the pane's only identity: two panes sharing a key are both active at once.
The intended call shape is the container with its props (default_active, tab_position, animated, class, on_change) and one bare children block holding the panes, each pane carrying item_key, tab, disabled, icon, a bare children block and class.
The props that do not move
TabPosition::Right / Bottom / Left change only the root's position class. The nav is whatever the stylesheet makes of the position class, the ink bar is always empty, and the content region always follows the nav — so the three variants differ in the class name, not in the layout.
animated likewise only adds or drops hk-tabs-animated; no Rust code here reads the ink bar or measures a pane. on_change is declared and never invoked: neither component wires it to anything, and selection cannot change anyway (see above).
TabPane::icon is a free-form Element, wrapped in the 16px-ish icon cell as given; render the glyph at the size you want. disabled reaches aria-disabled and a class, but not a real disabled attribute — the trigger is a div, so it stays focusable and clickable-looking and nothing suppresses a press.
API
Rust
Props — Tabs
| Prop | Type | Default | Description |
|---|---|---|---|
| default_active | String | "" | — |
| tab_position | TabPosition | TabPosition::Top | — |
| animated | bool | true | — |
| class | String | "" | — |
| children | Element | (empty) | — |
| on_change | Option<EventHandler<String>> | None | — |
Props — TabPane
| Prop | Type | Default | Description |
|---|---|---|---|
| item_key | String | "" | — |
| tab | String | "" | — |
| disabled | bool | false | — |
| icon | Option<Element> | None | — |
| children | Element | (empty) | — |
| class | String | "" | — |
Accessibility
- The two roles are the good part of this surface: the nav carries role="tablist", each TabPane contributes a role="tab" with data-key and aria-selected, and its body is a role="tabpanel" with aria-hidden while inactive. A screen reader therefore gets the pattern even though the visual state is not driven by the container.
- The names are missing. The tablist has no aria-label and each tab has no id / aria-controls; the panel has no aria-labelledby. Neither side links a tab to its panel, so assistive technology cannot connect the two halves of the pattern, and a page with several strips gives several unnamed tablists.
- Disabled is not disabled. disabled writes aria-disabled on a div[role="tab"]; there is no native disabled, no tabindex management and no handler, so the state is announced but not enforced.
- Nothing is keyboard-operable. divs with a role carry no native activation; there is no arrow-key walk, no roving tabindex and no focus management. The strip is inert unless the host adds behaviour, and a host cannot add it without a working selection model — which this component does not have.
- Duplicated content. Because the same children are drawn in both regions, the panels are present twice in the document when the container is used as designed. Count the tabs and panels in the DOM before shipping a page built on it.
Related components
- HkTabs — the current strip, Vue-side, and its Rust mirror SegmentedTabs for the segmented variant.
- Menu (legacy) — the sibling legacy container in the same family: same era, same drift from its Vue nickname.
- AdaptiveTabs — the current answer for a tab bar that must keep its options reachable on a narrow screen.