Skip to content
iv-ui v0.3.0

Breadcrumb

since 0.2.0

Shows the path to the current page.

import { Breadcrumb } from '@elluzion/iv-ui';

Basic

Links for ancestors and plain text for the current page.

Source· svelte Show Hide
<script lang="ts">
	import { Breadcrumb } from '@elluzion/iv-ui';

	const items = [
		{ label: 'Projects', href: '#' },
		{ label: 'Orbital', href: '#' },
		{ label: 'Deployments' }
	];
</script>

<Breadcrumb {items} />
  • The last item without href renders as the current page.
  • Pass a separator snippet to replace the default chevron.
  • ariaLabel names the navigation landmark.

Icons

Each item can carry an icon snippet before its label.

Source· svelte Show Hide
<script lang="ts">
	import { IconFolder, IconHome } from '@tabler/icons-svelte';
	import { Breadcrumb } from '@elluzion/iv-ui';
</script>

{#snippet home()}<IconHome size={12} />{/snippet}
{#snippet folder()}<IconFolder size={12} />{/snippet}

<Breadcrumb
	items={[
		{ label: 'Home', href: '#', icon: home },
		{ label: 'Projects', href: '#', icon: folder },
		{ label: 'Orbital' }
	]}
/>

Custom separator

The separator snippet replaces the chevron.

Source· svelte Show Hide
<script lang="ts">
	import { Breadcrumb } from '@elluzion/iv-ui';

	const items = [
		{ label: 'Projects', href: '#' },
		{ label: 'Orbital', href: '#' },
		{ label: 'Settings' }
	];
</script>

{#snippet separator()}<span class="sep">/</span>{/snippet}

<Breadcrumb {items} {separator} />

<style>
	.sep {
		font-family: var(--iv_font-mono);
		font-size: var(--iv_text-sm);
		color: var(--iv_bracket);
	}
</style>
import { Breadcrumb } from '@elluzion/iv-ui';

Props

3 props · 0 events · 1 snippets
PropTypeDefaultDescription
items required BreadcrumbItem[]—Trail entries. The last item is rendered as the current page.
ariaLabel string'Breadcrumb'Accessible name for the navigation landmark.
className string''Extra classes merged onto the root element.

class, id, style, aria-*, and data-* are forwarded through rest props.

Snippets

SnippetTypeDescription
separatorSnippetCustom separator snippet; defaults to /.

Types

BreadcrumbItem

One entry in a breadcrumb trail.

type BreadcrumbItem = {
	label: string;
	href?: string;
	icon?: Snippet;
};
  • The trail is a <nav> with an accessible name.
  • The current page uses aria-current="page".
  • Separators are hidden from assistive technology.
Class hooks
.iv-breadcrumb.iv-breadcrumb-item.iv-breadcrumb-sep
iv-ui
↑ ↓ navigate ↵ open esc close minisearch · 482 records