Tabs

A Tabs component allows users to switch between different views or sections. Built on top of heroui-native Tabs with items-based API.

Demo

Demo Coming Soon

Tabs examples will be available soon.

Usage

import { useState } from 'react';
import { NTabs, NTabsContent } from '@nayan-ui/react';
const items = ['POSTS', 'SAVED'];
const Tabs = () => {
const [selected, setSelected] = useState(items[0]);
return (
<div>
<h1 className="text-foreground mb-3 text-lg text-left">Tabs:</h1>
<NTabs items={items} selected={selected} onChange={setSelected}>
<NTabsContent item={items[0]} className="px-3 py-2 text-foreground">
Content 1
</NTabsContent>
<NTabsContent item={items[1]} className="px-3 py-2 text-foreground">
Content 2
</NTabsContent>
</NTabs>
<h1 className="text-foreground mb-3 mt-5 text-lg text-left">Full Width:</h1>
<NTabs isFull={true} items={items} selected={selected} onChange={setSelected}>
<NTabsContent item={items[0]} className="px-3 py-2 text-foreground">
Content 3
</NTabsContent>
<NTabsContent item={items[1]} className="px-3 py-2 text-foreground">
Content 4
</NTabsContent>
</NTabs>
</div>
);
};
export default Tabs;

Attributes

NameTypeDefaultDetails
itemsTabItem[]RequiredArray of tab items with label, value, and optional content.
valuestringOptionalControlled active tab value.
defaultValuestringOptionalDefault active tab value.
onValueChange(value: string) => voidOptionalCallback when active tab changes.
variantstringOptionalTabs variant style.
classNamestring' 'You can customise by passing tailwind classes.
listClassNamestring' 'You can customise tab list by passing tailwind classes.
triggerClassNamestring' 'You can customise tab triggers by passing tailwind classes.
contentClassNamestring' 'You can customise tab content by passing tailwind classes.