API
Usage and API reference
CwSideNav is the primary navigation rail. It has three modes (open, mini icon rail, hidden) and, with `responsive`, picks one per breakpoint. On phones an open nav slides over the page with a scrim and traps focus until it closes.
Copy-paste examples
Each snippet is a complete, working example you can paste into a Svelte 5 component.
Responsive navigation
<script lang="ts">
import { CwSideNav } from '@cropwatchdevelopment/cwui';
import type { CwSideNavItem, CwSideNavMode } from '@cropwatchdevelopment/cwui';
import { page } from '$app/state';
let mode = $state<CwSideNavMode>('open');
const items: CwSideNavItem[] = [
{ id: 'dashboard', label: 'Dashboard', href: '/', group: 'Monitor' },
{ id: 'devices', label: 'Devices', href: '/devices', group: 'Monitor' },
{ id: 'reports', label: 'Reports', href: '/reports', group: 'Analyse' }
];
const withActive = $derived(items.map((item) => ({ ...item, active: item.href === page.url.pathname })));
</script>
<CwSideNav items={withActive} bind:mode responsive ariaLabel="Main">
{#snippet header()}<strong>CropWatch</strong>{/snippet}
</CwSideNav>