Breadcrumb
Usage
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>
Items
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.Separator Icon
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>
Examples
With separator slot
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>
With custom slot
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.API
Props
| Prop | Default | Type |
|---|---|---|
as | 'nav' | anyThe element or component this component should render as. |
items | T[] | |
separatorIcon | appConfig.pohon.icons.chevronRight | string | objectThe icon to use as a separator. |
labelKey | 'label' | keyof Extract<NestedItem<T>, object> & string | DotPathKeys<Extract<NestedItem<T>, object>>The key used to get the label from the item.
|
pohon | { root?: ClassValue; list?: ClassValue; item?: ClassValue; link?: ClassValue; linkLeadingIcon?: ClassValue; linkLeadingAvatar?: ClassValue; linkLeadingAvatarSize?: ClassValue; linkLabel?: ClassValue; separator?: ClassValue; separatorIcon?: ClassValue; } |
Slots
| Slot | Type |
|---|---|
item | { item: T; index: number; active?: boolean; pohon: object; } |
item-leading | { item: T; index: number; active?: boolean; pohon: object; } |
item-label | { item: T; index: number; active?: boolean; } |
item-trailing | { item: T; index: number; active?: boolean; } |
separator | { pohon: object; } |
Theme
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: []
}
}
};