Theme
Design your own
On this page (3)
Component Skill — components/breadcrumbs/component-skill.md

Native basis

A <div>: the Breadcrumb component (with a home icon), a back link to the parent shown only below 30rem (container query), and the page title. The collapsed variant puts the middle levels in a popover behind a "..." button.

Built from

Breadcrumb.

Web Platform APIs

<nav>aria-currentContainer queriesPopover APICSS anchor positioning

Classes

.mk-breadcrumbs.mk-breadcrumbs-back.mk-breadcrumbs-title.mk-breadcrumbs-more.mk-breadcrumbs-menu

Data attributes

data-variant="collapsed".

§Default

The Breadcrumb component (the home icon is named) above the title. Below 30rem of width - resize the preview to Mobile - a container query swaps the trail for "← Billing".

§Collapsed

data-variant='collapsed': deep trails keep the first and last levels; the middle ones open from "…" in a popover anchored to it.

§CSS view file

/* -- Breadcrumbs (website · Search & Navigation) --------------------------
   Shows the current position within a content hierarchy - the trail above the page title, collapsing to a back link on small screens, or hiding the middle levels in a menu. */
@layer components {
  /* every box in the block measures border-box - the same on any page */
  :where(.mk-breadcrumbs, .mk-breadcrumbs *, .mk-breadcrumbs ::before, .mk-breadcrumbs ::after) {
    box-sizing: border-box;
  }
  .mk-breadcrumbs {
    container: mk-breadcrumbs / inline-size;
    display: grid;
    gap: 0.5rem;
    width: 100%;
    & .breadcrumb-link svg {
      width: 0.875rem;
      height: 0.875rem;
      vertical-align: -0.125rem;
    }
  }
  .mk-breadcrumbs-back {
    display: none;
    align-items: center;
    gap: 0.25rem;
    width: fit-content;
    color: var(--muted-foreground);
    font-size: 0.875rem;
    text-decoration: none;
    & svg {
      width: 1rem;
      height: 1rem;
    }
    &:hover {
      color: var(--foreground);
    }
  }
  .mk-breadcrumbs-title {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
  }
  .mk-breadcrumbs-more {
    display: grid;
    place-items: center;
    width: 1.75rem;
    height: 1.5rem;
    padding: 0;
    border: 0;
    border-radius: var(--radius-sm);
    background: var(--muted);
    color: var(--muted-foreground);
    cursor: pointer;
    &:hover {
      color: var(--foreground);
    }
    &:focus-visible {
      outline: 2px solid var(--ring);
      outline-offset: 1px;
    }
    & svg {
      width: 1rem;
      height: 1rem;
    }
  }
  .mk-breadcrumbs-menu {
    margin: 0;
    padding: 0.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--popover);
    box-shadow: var(--shadow-lg);
    & ul {
      display: grid;
      margin: 0;
      padding: 0;
      list-style: none;
    }
    & a {
      display: block;
      padding: 0.375rem 0.75rem;
      border-radius: var(--radius-sm);
      color: var(--popover-foreground);
      font-size: 0.875rem;
      text-decoration: none;
    }
    & a:hover {
      background: var(--accent);
    }
  }
  @supports (position-anchor: --a) {
    .mk-breadcrumbs-menu {
      inset: auto;
      margin-block-start: 0.25rem;
      position-area: bottom span-right;
    }
  }
  @container mk-breadcrumbs (max-width: 30rem) {
    .mk-breadcrumbs:not([data-variant]) .breadcrumb {
      display: none;
    }
    .mk-breadcrumbs:not([data-variant]) .mk-breadcrumbs-back {
      display: inline-flex;
    }
  }
  /* -- Accessibility ------------------------------------------- */
  @media (forced-colors: active) {
    .mk-breadcrumbs-more {
      border: 1px solid ButtonText;
    }
  }
}

Comments, ideas or improvements? Edit this page's source on GitHub