ais-breadcrumb
<ais-breadcrumb :attributes="string[]" // Optional parameters root-path="string" separator="string" :transform-items="function" :class-names="object" />
1
2
3
4
5
6
7
8
9
import { AisBreadcrumb } from 'vue-instantsearch';
// Use 'vue-instantsearch/vue3/es' for Vue 3
export default {
components: {
AisBreadcrumb
},
// ...
};
1. Follow additional steps in Optimize build size to ensure your code is correctly bundled.
2. This imports all the widgets, even the ones you donβt use. Read the Getting started guide for more information.
About this widget
The breadcrumb
widget is a secondary navigation scheme that lets the user see where the current page is in relation to the facetβs hierarchy.
It reduces the number of actions a user needs to take to get to a higher-level page and improves the discoverability of the app or websiteβs sections and pages. Itβs commonly used for websites with lots of data, organized into categories with subcategories.
Requirements
The objects to use in the breadcrumb must follow this structure:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
[
{
"objectID": "321432",
"name": "lemon",
"categories.lvl0": "products",
"categories.lvl1": "products > fruits"
},
{
"objectID": "8976987",
"name": "orange",
"categories.lvl0": "products",
"categories.lvl1": "products > fruits"
}
]
Itβs also possible to provide more than one path for each level:
1
2
3
4
5
6
7
8
[
{
"objectID": "321432",
"name": "lemon",
"categories.lvl0": ["products", "goods"],
"categories.lvl1": ["products > fruits", "goods > to eat"]
}
]
The attributes provided to the widget must be in attributes for faceting, either on the dashboard) or using attributesForFaceting
with the API. By default, the separator is >
(with spaces) but you can use a different one by using the separator option.
If there is also a ais-hierarchical-menu
on the page, it must follow the same configuration.
Examples
1
2
3
4
5
6
7
8
<ais-breadcrumb
:attributes="[
'categories.lvl0',
'categories.lvl1',
'categories.lvl2',
'categories.lvl3',
]"
/>
Props
Parameter | Description | ||
---|---|---|---|
attributes
|
type: string[]
Required
An array of attributes to generate the breadcrumb. When using an array, take steps to avoid creating infinite loops. When you use an array as a prop, it causes the widget to re-register on every render, and this can sometimes cause these infinite loops. |
||
Copy
|
|||
root-path
|
type: string
Optional
The path to use if the first level is not the root level. Make sure to also include the root path in your UI stateβfor example, by setting |
||
Copy
|
|||
separator
|
type: string
default: >
Optional
The level separator used in the records. |
||
Copy
|
|||
transform-items
|
type: function
Optional
Receives the items and is called before displaying them. Should return a new array with the same shape as the original array. Useful for transforming, removing, or reordering items. In addition, the full |
||
Copy
|
|||
class-names
|
type: object
Optional
The CSS classes you can override:
|
||
Copy
|
Customize the UI
Parameter | Description | ||
---|---|---|---|
default
|
The slot to override the complete DOM output of the widget. Note that when you implement this slot, none of the other slots will change the output, as the default slot surrounds them. Scope
Where each item is an
|
||
Copy
|
|||
rootLabel
|
The slot to override the root label. |
||
Copy
|
|||
separator
|
The slot to override the separator. |
||
Copy
|
HTML output
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<div class="ais-Breadcrumb">
<ul class="ais-Breadcrumb-list">
<li class="ais-Breadcrumb-item">
<a class="ais-Breadcrumb-link" href="#">Home</a>
</li>
<li class="ais-Breadcrumb-item">
<span class="ais-Breadcrumb-separator" aria-hidden="true">></span>
<a class="ais-Breadcrumb-link" href="#">Cooking</a>
</li>
<li class="ais-Breadcrumb-item ais-Breadcrumb-item--selected">
<span class="ais-Breadcrumb-separator" aria-hidden="true">></span>
Kitchen textiles
</li>
</ul>
</div>
If SEO is critical to your search page, your custom HTML markup needs to be parsable:
- use plain
<a>
tags withhref
attributes for search engines bots to follow them, - use semantic markup with structured data when relevant, and test it.
Refer to our SEO checklist for building SEO-ready search experiences.