Skip to content

Tabs

A tab bar component for Ink 5. Shows labelled tabs with an active indicator, optional badges, and keyboard navigation support via parent onChange.

Install

Terminal window
npm install @matthesketh/ink-tabs

Usage

import { Tabs } from '@matthesketh/ink-tabs';
const tabs = [
{ id: 'home', label: 'Home' },
{ id: 'logs', label: 'Logs', badge: 3 },
{ id: 'settings', label: 'Settings' },
];
function App() {
const [activeId, setActiveId] = useState('home');
return <Tabs tabs={tabs} activeId={activeId} onChange={setActiveId} />;
}

Props

PropTypeDefaultDescription
tabsTab[]requiredArray of tab objects
activeIdstringrequiredID of the currently active tab
onChange(id: string) => voidCalled when a tab should change (parent handles input)
accentColorstring'cyan'Colour for the active tab
separatorstring' | 'String rendered between tabs

Tab

FieldTypeDescription
idstringUnique identifier
labelstringDisplay text
badgestring | numberOptional badge shown as (N) after label

License

MIT