Tabs
Peer views of one thing: a pill or underline that glides between tabs, panels that slide the way you moved, overflow edge buttons, counts that roll, and closable terminal tabs.
oxyn add tabsAtlas is healthy. 12 runs today, 2 waiting on review, $18.40 spent.
let tabs = vec![Tab::new("overview", "Overview"), Tab::new("runs", "Runs").count(24)];
rsx! {
Tabs {
tabs: tabs,
panels: vec!["Summary".into(), "Recent runs".into()],
on_change: move |v: String| route.set(v),
}
}Rendered from Rust at build time · goes live when visible
When to use
- Peer views of one object (Overview · Runs · Approvals · Settings), and the terminal strip of a coding agent where each tab is a shell that can be closed, added and keeps a busy dot while a command runs.
When not to use
- Switch between two to six options: use Segmented Control instead.
- Terminal tabs: use Terminal tabs instead.
- A project header that folds into a compact bar as the page scrolls, with breadcrumb, actions and tabs whose counts roll: use Page header instead.
Installation
Tabs is free and MIT. The oxyn CLI copies its code, and the components it needs, into src/oxyn/ of your Dioxus or GPUI project, so it is yours to change.
cargo install --git https://github.com/ismailqureshi72/Oxyn oxyn-cli
oxyn init
oxyn add tabsuse crate::oxyn::{Tabs, PRIMITIVES_CSS};Rather depend on the crate? cargo add oxyn-dioxus oxyn-core --git https://github.com/ismailqureshi72/Oxyn, then use oxyn_dioxus::{Tabs, PRIMITIVES_CSS};
Usage
let tabs = vec![Tab::new("overview", "Overview"), Tab::new("runs", "Runs").count(24)];
rsx! {
Tabs {
tabs: tabs,
panels: vec!["Summary".into(), "Recent runs".into()],
on_change: move |v: String| route.set(v),
}
}Examples
Pill
A gliding pill over a sunken strip.
Atlas is healthy. 12 runs today, 2 waiting on review, $18.40 spent.
Code
let tabs = vec![Tab::new("overview", "Overview"), Tab::new("runs", "Runs").count(24)];
rsx! {
Tabs {
tabs: tabs,
panels: vec!["Summary".into(), "Recent runs".into()],
on_change: move |v: String| route.set(v),
}
}Underline
An underline that slides.
Atlas is healthy. 12 runs today, 2 waiting on review, $18.40 spent.
Code
let tabs = vec![Tab::new("overview", "Overview"), Tab::new("runs", "Runs").count(24)];
rsx! {
Tabs {
tabs: tabs,
panels: vec!["Summary".into(), "Recent runs".into()],
variant: "underline",
on_change: move |v: String| route.set(v),
}
}Enclosed
Folder tabs over a rule (Oxyn plus).
Atlas is healthy. 12 runs today, 2 waiting on review, $18.40 spent.
Code
let tabs = vec![Tab::new("overview", "Overview"), Tab::new("runs", "Runs").count(24)];
rsx! {
Tabs {
tabs: tabs,
panels: vec!["Summary".into(), "Recent runs".into()],
variant: "enclosed",
on_change: move |v: String| route.set(v),
}
}Overflow
Too many tabs: the strip scrolls with edge buttons.
Atlas is healthy. 12 runs today, 2 waiting on review, $18.40 spent.
Code
let tabs = vec![Tab::new("overview", "Overview"), Tab::new("runs", "Runs").count(24)];
rsx! {
Tabs {
tabs: tabs,
panels: vec!["Summary".into(), "Recent runs".into()],
on_change: move |v: String| route.set(v),
}
}Terminal
Closable terminal tabs with busy dots and a + (Oxyn plus).
$ cargo test -p oxyn-core
Compiling oxyn-core v0.3.0
Running unittests src/lib.rs
test primitives::layout::tabs ... ok
test primitives::layout::tree ... ok
▌Code
let tabs = vec![Tab::new("overview", "Overview"), Tab::new("runs", "Runs").count(24)];
rsx! {
Tabs {
tabs: tabs,
panels: vec!["Summary".into(), "Recent runs".into()],
variant: "terminal",
on_change: move |v: String| route.set(v),
}
}API reference
Tabs
| Prop | Type | Default | Description |
|---|---|---|---|
tabsrequired | Vec<Tab> | — | Tabs. |
value | Option<String> | Default::default() | Selected value (initial). |
panels | Vec<String> | Default::default() | Panel text per tab (same order). |
variant | String | "pill" | `pill` · `underline` · `enclosed` · `terminal`. |
size | String | "md" | `sm` · `md`. |
manual | bool | Default::default() | Manual activation (arrows only move focus). |
label | String | "Tabs" | Tab list label. |
full | bool | Default::default() | Fill the width (equal tabs). |
addable | bool | Default::default() | Terminal variant: show the "+" button. |
on_change | EventHandler<String> | — | Selection changed. |
on_close | EventHandler<String> | — | A tab closed (value). |
children | Element | Default::default() | Extra content under the strip. |
Read from the Rust signature and doc comments.
Keyboard interactions
| Key | Action |
|---|---|
| ← → | Move between tabs (and select, unless manual) |
| HomeorEnd | First / last tab |
| EnterorSpace | Select the focused tab (manual) |
| Delete | Close the focused terminal tab |
| Tab | Into the panel |
Accessibility
- tablist / tab / tabpanel with aria-selected and aria-controls; one tab stop.
- Overflow buttons are labelled “Scroll tabs left / right”.
- The pill is aria-hidden; panels re-key so the old one never takes focus.
From the spec
tablist / tab / tabpanel with aria-controls and aria-labelledby; one tab stop. The outgoing panel is gone (re-keyed), so it can never take focus. Overflow buttons are tabindex=-1 because the arrows already reach every tab.
Motion & interaction
One pill per instance glides between triggers (transform + width, measured with onmounted); keyboard moves jump. Panels re-key on every change and slide 8 px from the side the selection came from. Counts roll up when they change; the close button fades in on hover or selection.
Timing
| Transition | Duration | Easing | Reduced motion |
|---|---|---|---|
| Pill glide | 240 ms | ease.out | jump |
| Panel slide | 240 ms | ease.out | fade |
| Count roll | 220 ms | ease.out | swap |
| Close fade | 120 ms | linear | instant |
Responsive behaviour
- The strip scrolls horizontally; edge buttons appear only when it overflows.
- Tabs keep a 5.5rem minimum width (sm drops it).
Edge cases (spec)
Many tabs scroll; focusing a tab keeps it in view. Closing the last terminal leaves an empty strip with only “+”. Disabled first tab: the tab stop moves to the first enabled tab. Labels never wrap; terminal labels ellipsize at 16ch.
Notes for AI
- Import
Tabsfromoxyn_dioxusand includePRIMITIVES_CSSplus the token stylesheet once. - A GPUI version exists:
TabsElinoxyn_gpui. - Props to set first:
tabs. - Keep its states and timings as they ship; restyle it through the CSS variables rather than by hand.