Use the Breadcrumb component to show the current page's location in your site's hierarchy.
<script setup lang="ts">
const items = ref([
{
label: 'Docs',
icon: 'i-lucide:book-open',
to: '/docs/pohon'
},
{
label: 'Components',
icon: 'i-lucide:box',
to: '/docs/pohon/components'
},
{
label: 'Breadcrumb',
icon: 'i-lucide:link',
to: '/docs/pohon/components/breadcrumb'
}
])
</script>
<template>
<PBreadcrumb :items="items" />
</template>
Use the items prop as an array of objects with the following properties:
label?: stringicon?: stringavatar?: AvatarPropsslot?: stringclass?: anypohon?: { item?: ClassNameValue, link?: ClassNameValue, linkLeadingIcon?: ClassNameValue, linkLeadingAvatar?: ClassNameValue, linkLabel?: ClassNameValue, separator?: ClassNameValue, separatorIcon?: ClassNameValue }You can pass any property from the Link component such as to, target, etc.
<script setup lang="ts">
import type { PBreadcrumbItem } from 'pohon-ui'
const items = ref<PBreadcrumbItem[]>([
{
label: 'Docs',
icon: 'i-lucide:book-open',
to: '/docs/pohon'
},
{
label: 'Components',
icon: 'i-lucide:box',
to: '/docs/pohon/components'
},
{
label: 'Breadcrumb',
icon: 'i-lucide:link',
to: '/docs/pohon/components/breadcrumb'
}
])
</script>
<template>
<PBreadcrumb :items="items" />
</template>
span is rendered instead of a link when the to property is not defined.Use the separator-icon prop to customize the Icon between each item. Defaults to i-lucide:chevron-right.
<script setup lang="ts">
import type { PBreadcrumbItem } from 'pohon-ui'
const items = ref<PBreadcrumbItem[]>([
{
label: 'Docs',
icon: 'i-lucide:book-open',
to: '/docs/pohon'
},
{
label: 'Components',
icon: 'i-lucide:box',
to: '/docs/pohon/components'
},
{
label: 'Breadcrumb',
icon: 'i-lucide:link',
to: '/docs/pohon/components/breadcrumb'
}
])
</script>
<template>
<PBreadcrumb separator-icon="i-lucide:arrow-right" :items="items" />
</template>
Use the #separator slot to customize the separator between each item.
<script setup lang="ts">
import type { PBreadcrumbItem } from 'pohon-ui';
const items: Array<PBreadcrumbItem> = [
{
label: 'Docs',
to: '/docs/pohon',
},
{
label: 'Components',
to: '/docs/pohon/components',
},
{
label: 'Breadcrumb',
to: '/docs/pohon/components/breadcrumb',
},
];
</script>
<template>
<PBreadcrumb :items="items">
<template #separator>
<span class="color-text-muted mx-2">/</span>
</template>
</PBreadcrumb>
</template>
Use the slot property to customize a specific item.
You will have access to the following slots:
#{{ item.slot }}#{{ item.slot }}-leading#{{ item.slot }}-label#{{ item.slot }}-trailing<script setup lang="ts">
import type { PBreadcrumbItem } from 'pohon-ui';
const items = [
{
label: 'Home',
to: '/',
},
{
slot: 'dropdown' as const,
icon: 'i-lucide:ellipsis',
children: [
{
label: 'Documentation',
to: '/docs/pohon',
},
{
label: 'Themes',
},
{
label: 'GitHub',
},
],
},
{
label: 'Components',
to: '/docs/pohon/components',
},
{
label: 'Breadcrumb',
to: '/docs/pohon/components/breadcrumb',
},
] satisfies Array<PBreadcrumbItem>;
</script>
<template>
<PBreadcrumb :items="items">
<template #dropdown="{ item }">
<PDropdownMenu :items="item.children">
<PButton
:icon="item.icon"
color="neutral"
variant="link"
class="p-0.5"
/>
</PDropdownMenu>
</template>
</PBreadcrumb>
</template>
#item, #item-leading, #item-label and #item-trailing slots to customize all items.| Prop | Default | Type |
|---|
| Slot | Type |
|---|
Below is the theme configuration skeleton for the PBreadcrumb. Since the component is provided unstyled by default, you will need to fill in these values to apply your own custom look and feel. If you prefer to use our pre-built, opinionated styling, you can instead use our UnoCSS preset, this docs is using it as well.
export default defineAppConfig({
pohon: {
breadcrumb: {
slots: {
root: '',
list: '',
item: '',
link: '',
linkLeadingIcon: '',
linkLeadingAvatar: '',
linkLeadingAvatarSize: '',
linkLabel: '',
separator: '',
separatorIcon: ''
},
variants: {
active: {
true: {
link: ''
},
false: {
link: ''
}
},
disabled: {
true: {
link: ''
}
},
to: {
true: ''
}
},
compoundVariants: []
}
}
};
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import pohon from 'pohon-ui/vite'
export default defineAppConfig({
pohon: {
breadcrumb: {
slots: {
root: '',
list: '',
item: '',
link: '',
linkLeadingIcon: '',
linkLeadingAvatar: '',
linkLeadingAvatarSize: '',
linkLabel: '',
separator: '',
separatorIcon: ''
},
variants: {
active: {
true: {
link: ''
},
false: {
link: ''
}
},
disabled: {
true: {
link: ''
}
},
to: {
true: ''
}
},
compoundVariants: []
}
}
};