Files
plainleaf/plug-api/ui/tabs.tsx
T
Zef Hemel 3a8aaf2486 Beginnings of a design system for UI components
Right now mostly extracted from configuration-manager and SilverBullet+'s dashboard. Will be used in more plugs moving forward.
2026-06-01 13:16:57 +02:00

32 lines
623 B
TypeScript

import { cx } from "./cx.ts";
export type TabItem = {
label: string;
active?: boolean;
onSelect: () => void;
};
export type TabsProps = {
items: TabItem[];
class?: string;
};
export function Tabs({ items, class: extra }: TabsProps) {
return (
<div class={cx("sb-tabs", extra)} role="tablist">
{items.map((t) => (
<button
key={t.label}
type="button"
role="tab"
aria-selected={!!t.active}
class={cx("sb-tab", t.active && "sb-active")}
onClick={t.onSelect}
>
{t.label}
</button>
))}
</div>
);
}