Tabs#

A focusable horizontal tab switcher. The active tab fills with the accent; ←/→ (or h/l) switch.

Import#

TSX
import { Tabs } from '@sigx/terminal';
import type { TabOption } from '@sigx/terminal';

Usage#

TSX
/** @jsxImportSource @sigx/terminal */
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#

PropTypeNotes
optionsTabOption[]required — the tabs
modelModel<string>two-way bound active value
autofocusbooleangrab focus on mount

Events#

EventPayloadWhen
changestringactive tab changes

TabOption#

TypeScript
interface TabOption<T = string> {
    label: string;
    value: T;
}

See also#