To create a tab navigation, use the <TabNav> and <TabNavItem> components.
basePathactive prop on TabNavItem.pathnamepage.url.pathname from $app/state. Only used with basePath. Falls back to window.location.pathname when not passed - pass it in SvelteKit apps for a correctly
server-rendered active tab.gotogoto function (optional), e.g. from $app/navigation. Only used with basePath. Enables client-side
navigation - falls back to a normal navigation when not passed.replaceStatebasePath and goto.defaultnameactivetrue to make the tab active (optional). Only use if you want to control the
active tab from outside.defaultstartendTabNav does not depend on SvelteKit, so it also works in non-SvelteKit Svelte apps.
In a SvelteKit app, pass pathname and goto so that the active tab is rendered
correctly on the server and tab clicks navigate client-side without a full page reload. If they are
not passed, a normal (full-page) navigation is used instead.
<script lang="ts">
import { TabNav, TabNavItem } from '@hyvor/design';
import { page } from '$app/state';
import { goto } from '$app/navigation';
</script>
<TabNav basePath="/settings" pathname={page.url.pathname} {goto}>
<TabNavItem name="settings" index>
{#snippet start()}
<IconGear />
{/snippet}
Settings
</TabNavItem>
<TabNavItem name="seo">
{#snippet start()}
<IconSearchHeart />
{/snippet}
SEO
{#snippet end()}
<Tag size="x-small" color="green">80%</Tag>
{/snippet}
</TabNavItem>
<TabNavItem name="links">
{#snippet start()}
<IconLink45deg />
{/snippet}
Links
</TabNavItem>
</TabNav><script lang="ts">
import { TabNav, TabNavItem } from '@hyvor/design';
let active = 'settings';
</script>
<TabNav>
<TabNavItem name="settings" active={active === 'settings'} onclick={() => active = 'settings'}>
{#snippet start()}
<IconGear />
{/snippet}
Settings
</TabNavItem>
<TabNavItem name="seo" active={active === 'seo'} onclick={() => active = 'seo'}>
{#snippet start()}
<IconSearchHeart />
{/snippet}
SEO
{#snippet end()}
<Tag size="x-small" color="green">80%</Tag>
{/snippet}
</TabNavItem>
<TabNavItem name="links" active={active === 'links'} onclick={() => active = 'links'}>
{#snippet start()}
<IconLink45deg />
{/snippet}
Links
</TabNavItem>
</TabNav>Active tab is settings