MobileNav
The same destinations, arranged for a narrow viewport.
Mobile navigation is fixed to the bottom of the shell below 767px. The shell preview shows it when the viewport is narrow.
Open the shellSource
<script lang="ts">
import 'portal-bits/styles.css';
import 'portal-bits/tokens.css';
import type { Snippet } from 'svelte';
let { children }: { children: Snippet } = $props();
</script>
{@render children()}
<script lang="ts">
import MobileNavExample from './MobileNavExample.svelte';
</script>
<MobileNavExample />
<script lang="ts">
import { MobileNav, type NavItem } from 'portal-bits';
// This example uses @lucide/svelte for the navigation icons. Omit `icon` to skip it.
import { Component, Layers, LayoutGrid } from '@lucide/svelte';
const items: NavItem[] = [
{ href: '#overview', label: 'Overview', icon: LayoutGrid },
{ href: '#foundations', label: 'Foundations', icon: Layers },
{ href: '#components', label: 'Components', icon: Component },
];
// The consumer supplies the active URL. In SvelteKit, use the current pathname.
const active = '#overview';
</script>
<!-- MobileNav is fixed to the bottom of the viewport below 767px. -->
<MobileNav {items} {active} />
API reference
These tables list the props and snippets that MobileNav declares. Attributes passed through to an element or primitive are listed under Forwarded attributes, not here.
Props
| Name | Type | Default | Required | Binding | Description |
|---|---|---|---|---|---|
items | NavItem[] | None | Yes | One-way | Navigation items as `{ href, label, icon?, count? }`. |
active | string | None | Yes | One-way | The `href` of the current item. It gets `aria-current="page"`. |
Forwarded attributes
None. MobileNav forwards no attributes.
No data attributes are documented as stable.
Limits
- The `nav` is always named "Mobile navigation".
- `count` is not shown. Only the icon and label render.
- The narrow breakpoint is an adaptation.