Tabs
A responsive tabs component that collapses into a dropdown menu on mobile devices.
Import
import Tabs from "$lib/components/Tabs.svelte"; Basic Example
Tab 1
<Tabs tabs={['Tab 1', 'Tab 2', 'Tab 3']}>
<svelte:fragment slot="0">
<div class="rounded-md bg-background-alt p-4">
Content for Tab 1
</div>
</svelte:fragment>
<svelte:fragment slot="1">
<div class="rounded-md bg-background-alt p-4">
Content for Tab 2
</div>
</svelte:fragment>
<svelte:fragment slot="2">
<div class="rounded-md bg-background-alt p-4">
Content for Tab 3
</div>
</svelte:fragment>
</Tabs>Styled Example
Profile
<Tabs
tabs={['Profile', 'Settings', 'Notifications']}
tab_class="font-semibold"
content_class="bg-background-alt rounded-md p-4"
mobile_trigger_class="bg-texas-rose-500 text-white hover:bg-texas-rose-600"
>
<svelte:fragment slot="0">
<h3 class="text-lg font-medium">Profile Settings</h3>
<p class="mt-2">Manage your profile information here.</p>
</svelte:fragment>
<svelte:fragment slot="1">
<h3 class="text-lg font-medium">Account Settings</h3>
<p class="mt-2">Configure your account preferences.</p>
</svelte:fragment>
<svelte:fragment slot="2">
<h3 class="text-lg font-medium">Notification Settings</h3>
<p class="mt-2">Manage your notification preferences.</p>
</svelte:fragment>
</Tabs>Properties
Name
Type
Description
tabs
Type
string[]
Default: []
Array of tab labels to display (maximum of 6 tabs supported).
activeTab
Type
number
Default: 0
Index of the currently active tab.
class_name
Type
string
Default: ""
Additional classes for the root element.
tab_class
Type
string
Default: ""
Additional classes for the tab buttons.
content_class
Type
string
Default: ""
Additional classes for the content container.
mobile_trigger_class
Type
string
Default: ""
Additional classes for the mobile trigger button.