Breadcrumb
CBreadcrumb provides contextual information about page hierarchy.
Basic
CBreadcrumb requires a collection of menuitems as its model, the root item is defined with the home property.
vue
<template>
<CBreadcrumb :home="home" :model="items" />
</template>
<script setup lang="ts">
import { ref } from 'vue';
const home = ref({
icon: 'pi pi-home'
});
const items = ref([
{ label: 'Electronics' },
{ label: 'Computer' },
{ label: 'Accessories' },
{ label: 'Keyboard' },
{ label: 'Wireless' }
]);
</script>Template
Custom content can be placed inside the items using the item template. The divider between the items has its own separator template.
vue
<template>
<CBreadcrumb :home="home" :model="items">
<template #item="{ item }">
<a class="cursor-pointer text-primary hover:text-color" :href="item.url">
<span :class="item.icon"></span>
</a>
</template>
<template #separator>
<span class="text-primary">/</span>
</template>
</CBreadcrumb>
</template>
<script setup lang="ts">
import { ref } from 'vue';
const home = ref({ icon: 'pi pi-home' });
const items = ref([
{ icon: 'pi pi-sitemap' },
{ icon: 'pi pi-book' },
{ icon: 'pi pi-wallet' },
{ icon: 'pi pi-shopping-bag' },
{ icon: 'pi pi-calculator' }
]);
</script>Router
Items with navigation are defined with templating to be able to use a router link component, an external link or programmatic navigation.
vue
<template>
<CBreadcrumb :home="routerHome" :model="routerItems">
<template #item="{ item, props }">
<a v-if="item.url" :href="item.url" :target="item.target" v-bind="props.action">
<span class="text-blue-500 hover:text-blue-700">{{ item.label }}</span>
</a>
<div v-else>
{{ item.label }}
</div>
</template>
</CBreadcrumb>
</template>
<script setup lang="ts">
import { ref } from 'vue';
const home = ref({
label: 'home',
url: '/'
});
const items = ref([{ label: 'Components' }, { label: 'Form' }, { label: 'InputText', url: '/components/input-text.html' }]);
</script>