Navigation
Docs navigation
The page list of a documentation site or guide: links in groups under small uppercase labels, the current page filled in, long titles wrapping instead of being cut. It scrolls with the page, so put it in a sticky column on wide screens and in a Dialog sheet on phones. For an app with a collapsible rail, use Sidebar layout.
Installation
npx sinaui add docs-navCopy src/lib/ui/DocsNav.svelte, glide.ts, motion.ts and tokens.css. No dependencies.
Examples
Grouped pages
This page's sections in two groups. Choosing one marks it current; a badge flags something new.
<script lang="ts">
import DocsNav from '#lib/ui/DocsNav.svelte';
// This page's own sections, so every link goes somewhere.
const groups = [
{
title: 'Get started',
items: [
{ label: 'Installation', href: '#installation' },
{ label: 'Examples', href: '#examples', badge: 'New' }
]
},
{
title: 'Reference',
items: [
{ label: 'Props', href: '#props' },
{ label: 'Accessibility', href: '#accessibility' }
]
}
];
let current = $state('#examples');
</script>
<div class="frame">
<DocsNav label="This page" {groups} {current} onselect={(item) => (current = item.href)} />
</div>
<style>
.frame {
inline-size: min(15rem, 100%);
}
</style>Props
| Prop | Type | Default |
|---|---|---|
label | string (required): names the navigation | |
groups | { title?, items: { label, href, badge? }[] }[] (required) | |
current | string: href of the page being shown | |
onselect | (item) => void: after a page is chosen, e.g. to close a sheet |
Accessibility
- A
navnamed bylabel; each group's list is named by its label. - The current page has
aria-current="page"and a fill, not color alone. - Rows are 44px tall on touch screens.