Tabs
A focusable horizontal tab switcher. The active tab fills with the accent; ←/→ (or h/l) switch.
Import
import { Tabs } from '@sigx/terminal';
import type { TabOption } from '@sigx/terminal';
Usage
import { component, defineApp, signal, Tabs } from '@sigx/terminal';
import type { TabOption } from '@sigx/terminal';
const tabs: TabOption[] = [
{ label: 'Overview', value: 'overview' },
{ label: 'Logs', value: 'logs' },
{ label: 'Settings', value: 'settings' },
];
const App = component(() => {
const active = signal('overview');
return () => (
<box border="rounded" label="Panel">
<Tabs options={tabs} model={() => active} autofocus onChange={(v) => console.log(v)} />
<br />
<text>Active: {active.value}</text>
</box>
);
});
defineApp(<App />).mount({ clearConsole: true });
Props
| Prop | Type | Notes |
|---|---|---|
options | TabOption[] | required — the tabs |
model | Model<string> | two-way bound active value |
autofocus | boolean | grab focus on mount |
Events
| Event | Payload | When |
|---|---|---|
change | string | active tab changes |
TabOption
interface TabOption<T = string> {
label: string;
value: T;
}
