BreadcrumbsCommunity Asset
Breadcrumbs show the navigation path users followed to arrive at the current page, making it simple to return to earlier sections.
- Product
- Provet Cloud
- Availability
- New Frontend
View RTL<script setup lang="ts">
const route = useRoute()
const breadcrumbs = ref<BreadcrumbsType>({
category: 'common.breadcrumbs.label',
items: [
{
label: 'Breadcrumbs 1',
to: {
path: route.path,
query: { consultation_id: 1 },
},
},
{
label: 'Breadcrumbs 2',
to: {
path: route.path,
query: { consultation_id: 2 },
},
},
],
})
useBreadcrumbs().mutate(breadcrumbs.value)
</script>
<template>
<TheBreadcrumbs />
</template>
<script setup lang="ts">
const route = useRoute()
const breadcrumbs = ref<BreadcrumbsType>({
category: 'common.breadcrumbs.label',
items: [
{
label: 'Breadcrumbs 1 (external)',
to: 'https://nordhealth.design',
external: true,
target: '_blank',
},
{
label: 'Breadcrumbs 2',
to: {
path: route.path,
query: { consultation_id: 2 },
},
},
],
})
useBreadcrumbs().mutate(breadcrumbs.value)
</script>
<template>
<TheBreadcrumbs />
</template>
<script setup lang="ts">
const route = useRoute()
const maxBreadcrumbs = 5
const breadcrumbsCount = ref(2)
const breadcrumbs = ref<BreadcrumbsType>({
category: 'common.breadcrumbs.label',
items: [],
})
function updateBreadcrumbsCount(event: Event) {
breadcrumbsCount.value = Number((event.target as HTMLInputElement).value)
}
watchEffect(() => {
breadcrumbs.value.items = []
for (let step = 0; step < breadcrumbsCount.value; step++) {
if (breadcrumbsCount.value === 1 || step === breadcrumbsCount.value - 1) {
breadcrumbs.value.items.push({
label: `Breadcrumbs ${pad(step + 1)}`,
to: { path: route.path, query: { consultation_id: step } },
})
} else {
breadcrumbs.value.items.push({
label: `Breadcrumbs ${pad(step + 1)}`,
to: { path: route.path, query: { consultation_id: pad(step + 1, 9) } },
})
}
}
useBreadcrumbs().mutate(breadcrumbs.value)
})
</script>
<template>
<div class="n-stack n-gap-m">
<TheBreadcrumbs />
<nord-card padding="l">
<h2 slot="header">Breadcrumbs component</h2>
<div class="n-stack n-gap-m">
<nord-range
label="Breadcrumbs count"
:value="breadcrumbsCount.toString()"
:min="1"
:max="maxBreadcrumbs"
@input="updateBreadcrumbsCount"
/>
<p>See the example below.</p>
<code
class="n-border n-color-background n-color-text n-padding-s n-border-radius n-border n-color-status-neutral-weak n-border-radius"
>
useBreadcrumbs().mutate({{ breadcrumbs }})
</code>
</div>
</nord-card>
</div>
</template>
<style scoped>
code {
white-space: pre-wrap;
}
</style>
<script setup lang="ts">
const route = useRoute()
const breadcrumbs = ref<BreadcrumbsType>({
category: 'common.breadcrumbs.label',
items: [
{
label: 'Breadcrumbs 1 (new tab)',
to: {
path: route.path,
query: { consultation_id: 1 },
},
target: '_blank',
},
{
label: 'Breadcrumbs 2',
to: {
path: route.path,
query: { consultation_id: 2 },
},
},
],
})
useBreadcrumbs().mutate(breadcrumbs.value)
</script>
<template>
<TheBreadcrumbs />
</template>
Usage #
This section includes guidelines for designers and developers about the usage of this pattern in different contexts.
Do #
- Use breadcrumbs to display a hierarchy of pages and improve navigation.
- Include breadcrumbs to represent a hierarchy with multiple parent pages.
- Show the current page in the breadcrumbs if its title is not visible elsewhere on the page.
Don’t #
- Avoid using breadcrumbs if the page only has a single parent page. Use a Link instead.
- Don't use breadcrumbs to indicate progress in a task.
- Prevent redundancy. Exclude the current page from breadcrumbs if its title is already displayed on the page.
Integration
This community asset is currently only available to use in the New Frontend for Provet Cloud.
Troubleshooting
If you experience any issues while using this community asset, please ask for support in the #vet-frontend Slack channel.