Skip to content
API 风格:

Breadcrumb ​

Hierarchical path navigation built on native nav + ol semantics. The current page is marked with aria-current="page" and rendered as plain text; separators and collapsing are customizable.

Basic Usage ​

Basic Usage
vue
<script setup lang="ts">
</script>

<template>
  <LhBreadcrumb>
    <LhBreadcrumbItem>Home</LhBreadcrumbItem>
    <LhBreadcrumbItem>Components</LhBreadcrumbItem>
    <LhBreadcrumbItem>Breadcrumb</LhBreadcrumbItem>
  </LhBreadcrumb>
</template>
vue
<script>
export default {}
</script>

<template>
  <LhBreadcrumb>
    <LhBreadcrumbItem>Home</LhBreadcrumbItem>
    <LhBreadcrumbItem>Components</LhBreadcrumbItem>
    <LhBreadcrumbItem>Breadcrumb</LhBreadcrumbItem>
  </LhBreadcrumb>
</template>
Link Navigation
vue
<script setup lang="ts">
</script>

<template>
  <LhBreadcrumb>
    <LhBreadcrumbItem to="/">Home</LhBreadcrumbItem>
    <LhBreadcrumbItem to="/en/guide">Guide</LhBreadcrumbItem>
    <LhBreadcrumbItem>Current Page</LhBreadcrumbItem>
  </LhBreadcrumb>
</template>
vue
<script>
export default {}
</script>

<template>
  <LhBreadcrumb>
    <LhBreadcrumbItem to="/">Home</LhBreadcrumbItem>
    <LhBreadcrumbItem to="/en/guide">Guide</LhBreadcrumbItem>
    <LhBreadcrumbItem>Current Page</LhBreadcrumbItem>
  </LhBreadcrumb>
</template>
Replace mode
vue
<script setup lang="ts">
</script>

<template>
  <LhBreadcrumb>
    <LhBreadcrumbItem to="/" replace>Replace history</LhBreadcrumbItem>
    <LhBreadcrumbItem>Current page</LhBreadcrumbItem>
  </LhBreadcrumb>
</template>
vue
<script>
export default {}
</script>

<template>
  <LhBreadcrumb>
    <LhBreadcrumbItem to="/" replace>Replace history</LhBreadcrumbItem>
    <LhBreadcrumbItem>Current page</LhBreadcrumbItem>
  </LhBreadcrumb>
</template>

Items with to render as <a>; when vue-router is detected the navigation goes through the router (replace controls history replacement), otherwise it stays native. The last item always renders as the current-page text.

Custom Separator ​

Custom Separator
vue
<script setup lang="ts">
</script>

<template>
  <LhBreadcrumb separator="·">
    <LhBreadcrumbItem to="/">Home</LhBreadcrumbItem>
    <LhBreadcrumbItem to="/en/components">Components</LhBreadcrumbItem>
    <LhBreadcrumbItem>
      <template #separator>➜</template>
      Own Separator
    </LhBreadcrumbItem>
  </LhBreadcrumb>
</template>
vue
<script>
export default {}
</script>

<template>
  <LhBreadcrumb separator="·">
    <LhBreadcrumbItem to="/">Home</LhBreadcrumbItem>
    <LhBreadcrumbItem to="/en/components">Components</LhBreadcrumbItem>
    <LhBreadcrumbItem>
      <template #separator>➜</template>
      Own Separator
    </LhBreadcrumbItem>
  </LhBreadcrumb>
</template>

Collapsing ​

Collapsing
vue
<script setup lang="ts">
</script>

<template>
  <LhBreadcrumb :max-items="3">
    <LhBreadcrumbItem to="/">Home</LhBreadcrumbItem>
    <LhBreadcrumbItem to="/a">Level A</LhBreadcrumbItem>
    <LhBreadcrumbItem to="/a/b">Level B</LhBreadcrumbItem>
    <LhBreadcrumbItem to="/a/b/c">Level C</LhBreadcrumbItem>
    <LhBreadcrumbItem>Current Page</LhBreadcrumbItem>
  </LhBreadcrumb>
</template>
vue
<script>
export default {}
</script>

<template>
  <LhBreadcrumb :max-items="3">
    <LhBreadcrumbItem to="/">Home</LhBreadcrumbItem>
    <LhBreadcrumbItem to="/a">Level A</LhBreadcrumbItem>
    <LhBreadcrumbItem to="/a/b">Level B</LhBreadcrumbItem>
    <LhBreadcrumbItem to="/a/b/c">Level C</LhBreadcrumbItem>
    <LhBreadcrumbItem>Current Page</LhBreadcrumbItem>
  </LhBreadcrumb>
</template>

Beyond maxItems, the first item plus an ellipsis plus the trailing items stay visible; clicking the ellipsis expands everything.

Props ​

PropDescriptionTypeDefault
separatorSeparator characterstring'/'
maxItemsMax visible items (first + ellipsis + trailing items); collapses beyond itnumber0
sxsx quick-layout propsLhSxProps—

LhBreadcrumbItem Props ​

PropDescriptionTypeDefault
toLink target; renders as a link when set on non-last itemsstring—
replaceUse router replace when navigating via vue-routerbooleanfalse

Slots ​

SlotDescriptionComponent
defaultBreadcrumb itemsLhBreadcrumb
defaultItem contentLhBreadcrumbItem
separatorCustom separator (overrides the global separator)LhBreadcrumbItem

Accessibility ​

  • The root is <nav aria-label> (from the breadcrumb.label locale message) wrapping an <ol>; semantic order matches document order
  • The last item renders as text with aria-current="page" and stays unclickable even when to is set
  • Separators are aria-hidden="true" and excluded from the accessibility tree
  • The collapsed ellipsis is a real <button> whose aria-label comes from the breadcrumb.more locale message; clicking expands all items

Type Definitions ​

The TypeScript type structures exported by this component (auto-extracted from packages/components/breadcrumb/src/types.ts and @lh-ui/share/core/* sources; click each entry to expand; see the Props table above for attribute descriptions):

LhBreadcrumbProps
ts
export interface LhBreadcrumbProps {
  separator?: string
  maxItems?: number
  sx?: LhSxProps
}
LhBreadcrumbItemProps
ts
export interface LhBreadcrumbItemProps {
  to?: string
  replace?: boolean
}

Beauty of tradition, foundation of code