Interactive Tabs 2: Adding other components
Examples
It is possible to add other components to the `InteractiveTabs` component but using `InteractiveTabHead` and `TabContent` make it easy to add other components to tabs. Here we are adding a timeline component in the tab 1 and a card component in the tab 3:
-
Lorem ipsum dolor sit amet
Consectetur adipiscing elit...
Learn more -
Lorem ipsum dolor sit amet
Consectetur adipiscing elit...
-
Lorem ipsum dolor sit amet
Consectetur adipiscing elit...
<script>
import { InteractiveTabHead, TabContent, Card, Timeline,
TimelineItem, }from 'flowbite-svelte';
let tab1 = { name: 'Tab1', id: 1 };
let tab2 = { name: 'Tab2', id: 2 };
let tab3 = { name: 'Tab3', id: 3 };
let tabhead = [tab1, tab2, tab3];
let timelineItems = [
{
date: 'February 2022',
title: 'Lorem ipsum dolor sit amet',
href: '/',
linkname: 'Learn more',
text: 'Consectetur adipiscing elit...'
},
{
date: 'March 2022',
title: 'Lorem ipsum dolor sit amet',
text: 'Consectetur adipiscing elit...'
},
{
date: 'February 2022',
title: 'Lorem ipsum dolor sit amet',
text: 'Consectetur adipiscing elit...'
}
];
</script>
<InteractiveTabHead tabs={tabhead}>
<TabContent tab={tab1}>
<Timeline>
<TimelineItem {timelineItems} />
</Timeline>
</TabContent>
<TabContent tab={tab2}>
<p>Test 2 content here</p>
</TabContent>
<TabContent tab={tab3}>
<Card header="Card in a tab">
<span slot="paragraph">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Nulla distinctio.
</span>
</Card>
</TabContent>
</InteractiveTabHead>
Props
The component has the following props, type, and default values. See types page for type information.
InteractiveTabHead
Name | Type | Default |
---|---|---|
tabs | TabHeadType[] | |
tabId | string | 'myTab' |
activeTabValue | number | 1 |
TabContent
Name | Type | Default |
---|---|---|
divClass | string | 'p-4 rounded-lg dark:bg-gray-800' |
tab | TabHeadType |