Components › Components

On this page

Breadcrumb

Where a page sits in the site, as links back up.

Usage #

tscl
@import uiBreadcrumb from './breadcrumb.tscl'

<div class="demo">
  <uiBreadcrumb [items]="[{ label: 'Home', href: '/' }, { label: 'Components', href: '/' }, { label: 'Breadcrumb' }]" />
</div>

<style scoped>
  :scope {
    display: grid;
    gap: 12px;
    padding: 24px;
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius);
    background: var(--ui-bg);
    color: var(--ui-fg);
  }
</style>

Source #

Copy it next to your components as breadcrumb.tscl.

tscl
{{-- Breadcrumb: where this page sits. items: { label, href? }[]; the last is the current page. --}}
@input items: { label: string; href?: string }[]

<nav aria-label="Breadcrumb" data-part="breadcrumb">
  <ol data-part="breadcrumb-list">
    @for (item of items; track $index) {
      <li data-part="breadcrumb-item">
        @if ($last) {
          <span aria-current="page" data-part="breadcrumb-page">{{ item.label }}</span>
        } @else if (item.href) {
          <a [href]="item.href">{{ item.label }}</a>
        } @else {
          <span>{{ item.label }}</span>
        }
      </li>
    }
  </ol>
</nav>

<style scoped>
  @layer theme, base, components, utilities;
  @layer components {
    :where([data-part='breadcrumb-list']) {
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
      margin: 0;
      padding: 0;
      list-style: none;
      color: var(--ui-muted);
      font: var(--ui-font-size) var(--ui-font);
    }
    :where([data-part='breadcrumb-item']:not(:last-child))::after {
      content: '/' / '';
      margin-left: 6px;
      color: var(--ui-muted);
    }
    :where([data-part='breadcrumb-item'] a) {
      color: inherit;
    }
    :where([data-part='breadcrumb-item'] a:hover) {
      color: var(--ui-fg);
    }
    :where([data-part='breadcrumb-page']) {
      color: var(--ui-fg);
    }
  }
</style>

Styling #

Needs #