Tabs

A series of layered content sections, called tab panels, that are shown one at a time.

TabContent1

Installation

If @melio-ui/react is already installed globally, you can skip this step.

Import

  • TabsRoot: All parts of the tabs are included.
  • TabsList: Contains the buttons or tabs aligned with the edge of the active content.
  • TabsTab: This button activates related content.
  • TabsContent: Includes content related to each tab.

Another way to import

'use client';
import { Tabs } from '@melio-ui/tabs';
<Tabs.Root>
<Tabs.List>
<Tabs.Tab>Tab1</Tabs.Tab>
<Tabs.Tab>Tab2</Tabs.Tab>
</Tabs.List>
<Tabs.Content>
<p>TabContent1</p>
</Tabs.Content>
<Tabs.Content>
<p>TabContent2</p>
</Tabs.Content>
</Tabs.Root>;

'use client' must be used when rendering on the server side.

API Reference

TabsRoot

All parts of the tabs are included.

PropTypeDefaultDescription
valuestring-The value of the activated tab content.
defaultValuestring-The initial value of the activated tab content.
orientationTypeAttributes.Orientation

"horizontal" | "vertical"
-Direction for the placement of the Tabs component.
renderMode"selecting" | "selected" | "force""selecting"How to render tab content.

selecting: Rendering only the currently activated tab content.
selected: Rendering tab contents that have been activated.
force: Rendering all tab contents.
onValueChange(value: string) => void-The callback invoked when a tab content is activated.
Data attributeValues
[data-orientation]"horizontal" | "vertical"

TabsList

Contains the buttons or tabs aligned with the edge of the active content.

TabsTab

This button activates related content.

PropTypeDefaultDescription
valuestring-The value of the tab.
disabledboolean-Determines whether the tab is inactive.
Data attributeValues
[data-state]"active" | "inactive"
[data-disabled]Visible when disabled

TabsContent

Includes content related to each tab.

PropTypeDefaultDescription
valuestring-The value of the tab content.
Data attributeValues
[data-state]"active" | "inactive"

Examples

defaultValue

<TabsRoot defaultValue="tab2">
<TabsList>
<TabsTab value="tab1">Tab1</TabsTab>
<TabsTab value="tab2">Tab2</TabsTab>
<TabsTab value="tab3">Tab3</TabsTab>
</TabsList>
<TabsContent value="tab1">
<p>TabContent1</p>
</TabsContent>
<TabsContent value="tab2">
<p>TabContent2</p>
</TabsContent>
<TabsContent value="tab3">
<p>TabContent3</p>
</TabsContent>
</TabsRoot>

disabled tab

<TabsRoot>
<TabsList>
<TabsTab value="tab1">Tab1</TabsTab>
<TabsTab value="tab2" disabled>
Tab2
</TabsTab>
<TabsTab value="tab3">Tab3</TabsTab>
</TabsList>
<TabsContent value="tab1">
<p>TabContent1</p>
</TabsContent>
<TabsContent value="tab2">
<p>TabContent2</p>
</TabsContent>
<TabsContent value="tab3">
<p>TabContent3</p>
</TabsContent>
</TabsRoot>

Orientation

<TabsRoot orientation="vertical">
<TabsList>
<TabsTab value="tab1">Tab1</TabsTab>
<TabsTab value="tab2">Tab2</TabsTab>
<TabsTab value="tab3">Tab3</TabsTab>
</TabsList>
<TabsContent value="tab1">
<p>TabContent1</p>
</TabsContent>
<TabsContent value="tab2">
<p>TabContent2</p>
</TabsContent>
<TabsContent value="tab3">
<p>TabContent3</p>
</TabsContent>
</TabsRoot>
Prev
Next
DocsMelioUI
Copyright © Ahn Co. All rights reserved.