Tabs are used to switch between different views of a component.
"use client" import Tabs from "@radui/ui/Tabs"; import { useState } from "react"; const items = [ { id: "react", title: "React", content: "React is a JavaScript library for building user interfaces." }, { id: "angular", title: "Angular", content: "Angular is a platform and framework for building single-page client applications using HTML and TypeScript." }, { id: "vue", title: "Vue", content: "Vue.js is a progressive framework for building user interfaces." } ] const TabsExample = () => { const [activeTab, setActiveTab] = useState(items[0].id); return <div className="w-64 md:w-96"> <Tabs.Root value={activeTab} onValueChange={setActiveTab}> <Tabs.List> {items.map((item) => ( <Tabs.Trigger key={item.id} value={item.id}>{item.title}</Tabs.Trigger> ))} </Tabs.List> {items.map((item) => ( <Tabs.Content key={item.id} value={item.id}>{item.content}</Tabs.Content> ))} </Tabs.Root> </div> } export default TabsExample;
Import all parts of the component and piece them together
import Tabs from "@radui/ui/Tabs"; export default () => { return ( <Tabs.Root> <Tabs.List> <Tabs.Trigger /> </Tabs.List> <Tabs.Content /> </Tabs.Root> ) }
The root component for the Tabs.
Prop | Type | Default |
---|---|---|
className | string | -- |
customRootClass | string | -- |
children | ReactNode | |
value | string | -- |
color | string | -- |
defaultValue | string | -- |
onValueChange | function | -- |
The trigger component for the Tabs. This component is used to toggle the visibility of the Tab.
Prop | Type | Default |
---|---|---|
className | string | -- |
children | ReactNode | |
disabled | boolean | false |
value | string | -- |
The list component for the Tabs. This component is used to display the list of Tabs.
Prop | Type | Default |
---|---|---|
className | string | -- |
children | ReactNode |
The content component for the Tabs. This component is used to display the content of the Tabs.
Prop | Type | Default |
---|---|---|
className | string | -- |
value | string | -- |
children | ReactNode | -- |