mirror of
https://github.com/hanzoai/o11y-components.git
synced 2026-10-30 14:54:15 +00:00
A version written into a manifest is written into every manifest that wants it, which is how eslint came to exist in a hundred and four forms across this estate and how a package came to resolve twice at run time. The catalog moves the number out of the manifest: a manifest names the package, the workspace names the version. Four are held below their latest because the newer release cannot be used, and the reason is recorded rather than the version alone: @noble/hashes 2 renamed every subpath the web3 stack imports, @splinetool/runtime 2 depends on a package that was never published, @dynamic-labs 5.4.1 the same, and react-resizable-panels 3 points its types condition at the bundle.
143 lines
3.0 KiB
Plaintext
143 lines
3.0 KiB
Plaintext
import { Meta, Controls, Primary } from '@storybook/addon-docs/blocks';
|
|
import * as TabsStories from './tabs.stories';
|
|
import * as TabsRootStories from './tabs-root.stories';
|
|
import * as TabsListStories from './tabs-list.stories';
|
|
import * as TabsTriggerStories from './tabs-trigger.stories';
|
|
import * as TabsContentStories from './tabs-content.stories';
|
|
|
|
<Meta of={TabsStories} />
|
|
|
|
# Tabs
|
|
|
|
A flexible tabbed interface component with primary and secondary variants, supporting icons and disabled states.
|
|
|
|
## How to use
|
|
|
|
### Tabs (items-based API)
|
|
|
|
Use the main `Tabs` component with an `items` array for the most common use case:
|
|
|
|
```tsx
|
|
import { Tabs } from '@signozhq/ui';
|
|
import { Settings, CircleAlert } from '@signozhq/icons';
|
|
|
|
export default function MyComponent() {
|
|
const items = [
|
|
{
|
|
key: 'overview',
|
|
label: 'Overview',
|
|
children: 'Overview content',
|
|
prefixIcon: <Settings style={{ width: 16, height: 16 }} />,
|
|
},
|
|
{
|
|
key: 'issues',
|
|
label: 'Issues',
|
|
children: 'Issues content',
|
|
prefixIcon: <CircleAlert style={{ width: 16, height: 16 }} />,
|
|
},
|
|
];
|
|
|
|
return (
|
|
<Tabs
|
|
items={items}
|
|
variant="primary"
|
|
defaultValue="overview"
|
|
/>
|
|
);
|
|
}
|
|
```
|
|
|
|
### Controlled state
|
|
|
|
For controlled tabs, use `value` and `onChange`:
|
|
|
|
```tsx
|
|
import { Tabs } from '@signozhq/ui';
|
|
|
|
export default function MyComponent() {
|
|
const [activeTab, setActiveTab] = React.useState('tab1');
|
|
|
|
return (
|
|
<Tabs
|
|
variant="secondary"
|
|
value={activeTab}
|
|
onChange={setActiveTab}
|
|
items={[
|
|
{ key: 'tab1', label: 'Overview', children: <div>Overview content</div> },
|
|
{ key: 'tab2', label: 'Details', children: <div>Details content</div> },
|
|
]}
|
|
/>
|
|
);
|
|
}
|
|
```
|
|
|
|
### With icons and disabled tabs
|
|
|
|
```tsx
|
|
import { Tabs } from '@signozhq/ui';
|
|
import { House, Lock } from '@signozhq/icons';
|
|
|
|
<Tabs
|
|
items={[
|
|
{
|
|
key: 'home',
|
|
label: 'Home',
|
|
prefixIcon: <House />,
|
|
children: <div>Home</div>,
|
|
},
|
|
{
|
|
key: 'settings',
|
|
label: 'Settings',
|
|
disabled: true,
|
|
disabledReason: 'Coming soon',
|
|
children: <div>Settings</div>,
|
|
},
|
|
]}
|
|
/>
|
|
```
|
|
|
|
<Primary />
|
|
|
|
## Tabs Props
|
|
|
|
<Controls of={TabsStories.Default} />
|
|
|
|
## Primitive composition
|
|
|
|
For full control, use the low-level building blocks: `TabsRoot`, `TabsList`, `TabsTrigger`, and `TabsContent`.
|
|
|
|
```tsx
|
|
import { TabsRoot, TabsList, TabsTrigger, TabsContent } from '@signozhq/ui';
|
|
|
|
export default function MyComponent() {
|
|
return (
|
|
<TabsRoot defaultValue="tab1">
|
|
<TabsList variant="primary">
|
|
<TabsTrigger value="tab1">Tab 1</TabsTrigger>
|
|
<TabsTrigger value="tab2">Tab 2</TabsTrigger>
|
|
</TabsList>
|
|
<TabsContent value="tab1">Tab 1 content</TabsContent>
|
|
<TabsContent value="tab2">Tab 2 content</TabsContent>
|
|
</TabsRoot>
|
|
);
|
|
}
|
|
```
|
|
|
|
> Note: We do not recommend using primitive composition since the variant `primary` is not supported.
|
|
|
|
## TabsRoot Props
|
|
|
|
<Controls of={TabsRootStories.Default} />
|
|
|
|
## TabsList Props
|
|
|
|
<Controls of={TabsListStories.Default} />
|
|
|
|
## TabsTrigger Props
|
|
|
|
<Controls of={TabsTriggerStories.Default} />
|
|
|
|
## TabsContent Props
|
|
|
|
<Controls of={TabsContentStories.Default} />
|