Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 41 additions & 2 deletions packages/demo/src/components/demo/tabs.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Card, CardContent, Tabs } from "@eqtylab/equality";
import { Badge, Card, CardContent, Tabs } from "@eqtylab/equality";

export function TabsDemo({
variant = "default",
Expand All @@ -7,7 +7,8 @@ export function TabsDemo({
| "default"
| "with-icons"
| "with-active-fill"
| "with-icons-and-active-fill";
| "with-icons-and-active-fill"
| "with-suffix";
}) {
if (variant === "default") {
return (
Expand Down Expand Up @@ -146,5 +147,43 @@ export function TabsDemo({
);
}

if (variant === "with-suffix") {
return (
<Tabs
id="with-suffix-tabs"
items={[
{
label: "Declarations",
value: "declarations",
suffix: (
<Badge variant="neutral" size="sm">
12
</Badge>
),
content: (
<Card>
<CardContent>Declarations Content</CardContent>
</Card>
),
},
{
label: "Reviews",
value: "reviews",
suffix: (
<Badge variant="primary" size="sm">
3
</Badge>
),
content: (
<Card>
<CardContent>Reviews Content</CardContent>
</Card>
),
},
]}
/>
);
}

return null;
}
37 changes: 37 additions & 0 deletions packages/demo/src/content/components/tabs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,42 @@ Combine icons with the filled background variant for a more prominent tab design
/>
```

### With suffix

Use the `suffix` property to render any React component after a tab's label. This is useful for badges, counts, or status indicators. The suffix works alongside icons and both background variants:

<TabsDemo client:only="react" variant="with-suffix" />

#### Example

```tsx
<Tabs
id="with-suffix-tabs"
items={[
{
label: "Declarations",
value: "declarations",
suffix: (
<Badge variant="neutral" size="sm">
12
</Badge>
),
content: <div>Declarations Content</div>,
},
{
label: "Reviews",
value: "reviews",
suffix: (
<Badge variant="primary" size="sm">
3
</Badge>
),
content: <div>Reviews Content</div>,
},
]}
/>
```

## Props

---
Expand All @@ -190,4 +226,5 @@ Each item in the `items` array should have the following structure:
| `label` | Text label displayed on the tab trigger | `string` | - | ✅ |
| `value` | Unique value that identifies this tab | `string` | - | ✅ |
| `icon` | Icon to display alongside the label (Lucide name or element) | `React.ReactElement`, `string` | - | ❌ |
| `suffix` | Content rendered after the label (e.g. a badge or count) | `React.ReactNode` | - | ❌ |
| `content` | Content to display when this tab is active | `React.ReactNode` | - | ✅ |
4 changes: 3 additions & 1 deletion packages/ui/src/components/tabs/tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ interface TabsProps {
label: string;
value: string;
icon?: React.ReactElement | string;
suffix?: React.ReactNode;
content: React.ReactNode;
}[];
className?: string;
Expand Down Expand Up @@ -79,7 +80,7 @@ const Tabs = ({
isFilled ? styles['tabs-list--filled'] : styles['tabs-list--transparent']
)}
>
{items.map(({ label, value, icon }) => {
{items.map(({ label, value, icon, suffix }) => {
const isActive = activeTab === value;

return (
Expand All @@ -94,6 +95,7 @@ const Tabs = ({
>
{renderIcon(icon)}
{label}
{suffix}
{renderActiveStyle(isActive)}
</TabsTrigger>
);
Expand Down
Loading