/* * (c) Copyright 2026 Palantir Technologies Inc. All rights reserved. */ import type { Meta, StoryObj } from "@storybook/react-vite"; import { DashedPaddedContainer, storybookLayoutDecorator, StoryLabel } from "@storybook-common"; import { useCallback } from "react"; import { useArgs } from "storybook/preview-api"; import { Home } from "@blueprintjs/icons"; import { Flex } from "@blueprintjs/labs"; import { Colors } from "../../common"; import { Tab } from "./tab"; import { Tabs, type TabsProps } from "./tabs"; // These props are deprecated on Tabs — hide them from the Storybook controls panel. const disabledArgs = [ "large", "className", "children", "defaultSelectedTabId", "selectedTabId", "onChange", "id", "renderActiveTabPanelOnly", ] as const satisfies ReadonlyArray; const meta: Meta = { title: "Core/Tabs", component: Tabs, decorators: [storybookLayoutDecorator], args: { id: "tabs-story", animate: true, vertical: false, fill: false, size: "medium", }, argTypes: { size: { control: "select", options: ["medium", "large"], }, animate: { control: "boolean" }, vertical: { control: "boolean" }, fill: { control: "boolean" }, ...disabledArgs.reduce( (acc, argName) => { acc[argName] = { table: { disable: true } }; return acc; }, {} as Record<(typeof disabledArgs)[number], { table: { disable: boolean } }>, ), }, } satisfies Meta; export default meta; type Story = StoryObj; export const Default: Story = { render: args => ( First panel content

} /> Second panel content

} /> Third panel content

} />
), }; /** * Use the `size` prop to control the tab size. Tabs support `medium` (default) and `large`. */ export const SizeExample: Story = { name: "Size", argTypes: { size: { table: { disable: true } }, }, render: args => (
First panel

} /> Second panel

} /> Third panel

} />
First panel

} /> Second panel

} /> Third panel

} />
), }; /** * Tabs support vertical layout and individual tabs can be disabled. */ export const StateExample: Story = { name: "State", argTypes: { vertical: { table: { disable: true } }, }, render: args => (
First panel content

} /> Second panel content

} /> Third panel content

} />
Enabled panel content

} /> Disabled panel content

} /> Also enabled panel content

} />
), }; /** * Use the `fill` prop to make the tab list fill the height of its parent container. * * Whether to make the tabs list fill the height of its parent. * This has no effect when vertical={true}. */ export const FillExample: Story = { name: "Fill Height", argTypes: { fill: { table: { disable: true } }, vertical: { table: { disable: true } }, }, render: args => (
), }; /** * Use the `vertical` prop to display tabs in a vertical layout. * * In vertical mode, the tab list is rendered as a column alongside the tab panels. */ export const VerticalExample: Story = { name: "Vertical", argTypes: { vertical: { table: { disable: true } }, fill: { table: { disable: true } }, }, render: args => ( First panel content

} /> Second panel content

} /> Third panel content

} />
), }; /** * Tabs can display a `` next to the title using the `tagContent` prop. */ export const WithTagExample: Story = { name: "With Tag", render: args => ( Inbox panel content

} /> Sent panel content

} /> Drafts panel content

} />
), }; /** * Each tab can display an icon using the `icon` prop. */ export const IconExample: Story = { name: "Icon", render: args => ( Books panel content

} /> Documents panel content

} /> Applications panel content

} /> } panel={

Element icon panel

} />
), }; /** * Interactive playground for experimenting with all Tabs props. */ export const Playground: Story = { args: { selectedTabId: "tab1", }, render: function Render(args) { const [, updateArgs] = useArgs(); const handleChange = useCallback( (newTabId: string | number) => updateArgs({ selectedTabId: newTabId }), [updateArgs], ); return ( Photos panel content

} /> Videos panel content

} /> Music panel content

} /> Books panel content

} />
); }, };