@molecule/app-breadcrumb-vue
Feature · breadcrumb · App (browser) · v1.1.3 · Apache-2.0
Vue breadcrumb navigation component
npm install @molecule/app-breadcrumb-vueHow it works
@molecule/app-breadcrumb-vue is a ready-made breadcrumb feature for the app (browser) side. It composes the core interfaces it needs, so it works with whichever providers your app has bonded.
import { createApp, defineComponent, h } from 'vue'
import { Breadcrumb } from '@molecule/app-breadcrumb-vue'
const App = defineComponent({
setup() {
const navigate = (to: string): void => {
window.location.assign(to)
}
return () =>
h(Breadcrumb, {
items: [
{ label: 'Home', to: '/' },
{ label: 'Projects', to: '/projects' },
{ label: 'Apollo Redesign' },
],
onNavigate: navigate,
})
},
})
createApp(App).mount('#app')Works with: @molecule/app-ui, @molecule/app-ui-vue, @molecule/app-vue
Reference
Vue breadcrumb navigation component.
Exports <Breadcrumb> — a list of crumbs where each but the last is a
link. The final crumb renders as plain text with aria-current="page".
Pass onNavigate to intercept clicks and hand off to a router.
Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit
src/index.tsJSDoc, not this file.
Quick Start
import { createApp, defineComponent, h } from 'vue'
import { Breadcrumb } from '@molecule/app-breadcrumb-vue'
const App = defineComponent({
setup() {
const navigate = (to: string): void => {
window.location.assign(to)
}
return () =>
h(Breadcrumb, {
items: [
{ label: 'Home', to: '/' },
{ label: 'Projects', to: '/projects' },
{ label: 'Apollo Redesign' },
],
onNavigate: navigate,
})
},
})
createApp(App).mount('#app')
Type
feature
Installation
npm install @molecule/app-breadcrumb-vue @molecule/app-ui @molecule/app-ui-vue @molecule/app-vue vue
API
Interfaces
BreadcrumbItem
Describes a single crumb entry in a breadcrumb trail.
interface BreadcrumbItem {
/** Display text or VNode for the crumb. */
label: VNodeChild
/**
* Optional `to` target. When absent the crumb renders as plain text
* (typically the current page).
*/
to?: string
/** Optional leading icon. */
icon?: VNodeChild
}
BreadcrumbProps
Props accepted by the Breadcrumb component.
interface BreadcrumbProps {
/** Ordered list of crumbs, last one usually the current page. */
items: BreadcrumbItem[]
/**
* Click handler invoked with the target `to` when an item is clicked.
* Useful when wiring to a router. When omitted the component renders
* items with an anchor `<a href={to}>`. Bind it as `:on-navigate="…"`
* (or listen for `@navigate`).
*/
onNavigate?: (to: string) => void
/** Separator between crumbs — defaults to a `/`. Accepts any node. */
separator?: VNodeChild
/** Extra classes on the `<nav>` element. */
className?: string
/** `data-mol-id` for AI-agent selectors. */
dataMolId?: string
}
Constants
Breadcrumb
Breadcrumb navigation.
Each item before the last is rendered as a link; the last item is
rendered as plain text (the "current page"). Pass onNavigate to
intercept clicks (e.g. hand off to a router's navigate). Without it,
crumbs render as plain <a href> anchors.
The separator renders once per gap: a passed separator slot wins, then
the separator prop (cloned per gap, so one VNode fills every gap), then
the default <span aria-hidden>/</span>.
const Breadcrumb: DefineComponent<
ExtractPropTypes<{
items: { type: PropType<BreadcrumbItem[]>; default: () => never[] }
onNavigate: PropType<(to: string) => void>
separator: null
className: StringConstructor
dataMolId: StringConstructor
}>,
() => VNode,
{},
{},
{},
ComponentOptionsMixin,
ComponentOptionsMixin,
{},
string,
PublicProps,
Readonly<
ExtractPropTypes<{
items: { type: PropType<BreadcrumbItem[]>; default: () => never[] }
onNavigate: PropType<(to: string) => void>
separator: null
className: StringConstructor
dataMolId: StringConstructor
}>
> &
Readonly<{}>,
{ items: BreadcrumbItem[] },
{},
{},
{},
string,
ComponentProvideOptions,
true,
{},
any
>
props— Component props (seeBreadcrumbProps).
Returns: The breadcrumb component.
Injection Notes
Requirements
Peer dependencies:
@molecule/app-ui^1.0.1@molecule/app-ui-vue^1.1.0@molecule/app-vue^3.13.0 || ^4.0.0vue^3.4.0
Runtime Dependencies
@molecule/app-ui@molecule/app-ui-vue@molecule/app-vuevue
Without onNavigate, crumbs render as plain <a href> (full page
load in SPAs) — pass onNavigate={(to) => navigate(to)} to stay
client-side; with it, crumbs render as <button>s. The last item (or
any item without to) renders as plain text with aria-current="page".
No router dependency is required by the component itself. The separator
renders per gap: the separator slot wins, then the separator prop,
then the default /.
Translations
Translation strings are provided by @molecule/app-locales-breadcrumb.