Repository navigation
Tabs with underline #683
melvin-mendoza
started this conversation in
Ideas
Replies: 6 comments 4 replies
2 replies
|
If someone is interested, i have modified the original tabs component to allow Usage |
0 replies
2 replies
|
Thanks @tinywaves for the suggestion. You can extract the code to a re-usable component. import {Tabs, TabsContent, TabsList, TabsTrigger} from "@radix-ui/react-tabs";
interface Tab {
value: string;
label: string;
content: React.ReactNode;
}
interface DynamicTabsProps {
tabs: Tab[];
defaultValue: string;
}
const DynamicTabs: React.FC<DynamicTabsProps> = ({tabs, defaultValue}) => {
return (
<Tabs defaultValue={defaultValue}>
<TabsList
className="inline-flex h-9 items-center text-muted-foreground w-full justify-start rounded-none border-b bg-transparent p-0">
{tabs.map((tab) => (
<TabsTrigger
key={tab.value}
value={tab.value}
className="inline-flex items-center justify-center whitespace-nowrap py-1 text-sm ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background relative h-9 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 font-semibold text-muted-foreground shadow-none transition-none data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none"
>
{tab.label}
</TabsTrigger>
))}
</TabsList>
{tabs.map((tab) => (
<TabsContent key={tab.value} value={tab.value}>
{tab.content}
</TabsContent>
))}
</Tabs>
);
};
export default DynamicTabs;
//Usage
export default function Page() {
const tabs = [
{value: "items", label: "Items", content: <ItemList/>},
{value: "categories", label: "Categories", content: "Item categories here"},
];
return (<DynamicTabs tabs={tabs} defaultValue="items"/>);
} |
0 replies
|
You need to make sure you removed background, text color class from tabs component coming from components Tabs.... |
0 replies
|
Okay boys I looked around in <TabsList variant="line">
<TabsTrigger>
...And after that I looked at docs and what you expect, it has exact this example: |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment



Uh oh!
There was an error while loading. Please reload this page.
I would be nice to have a tabs with underline component
All reactions