Breadcrumbs
Where the page sits, as links, with the BreadcrumbList structured data. The current page carries aria-current.
Native .astro · no React · MIT · free, no account
Install
npx shadcn@latest add https://www.themes.dev/astro/r/breadcrumbs.jsonThe CLI needs a components.json (from npx shadcn init), which also writes the tokens these files use. It also installs JSON-LD, which it uses. No CLI? Copy the files below to the same paths.
Files
---// Where this page sits, as links, with the BreadcrumbList structured data for search results. The last item is the// current page: it is not a link and carries aria-current.// <Breadcrumbs items={[{ name: 'Home', href: '/' }, { name: 'Blog', href: '/blog/' }, { name: post.title, href: Astro.url.pathname }]} />import JsonLd from './JsonLd.astro';import { breadcrumbList } from '../lib/schema'; interface Props { items: { name: string; href: string }[]; /** Leave the structured data out (when the layout already prints it). */ schema?: boolean; label?: string; class?: string;}const { items, schema = true, label = 'Breadcrumb', class: className } = Astro.props;--- <nav aria-label={label} class:list={['text-sm', className]}> <ol class="flex flex-wrap items-center gap-1.5 text-muted-foreground"> { items.map((c, i) => { const last = i === items.length - 1; return ( <li class="inline-flex items-center gap-1.5"> {last ? ( <span aria-current="page" class="font-medium text-foreground">{c.name}</span> ) : ( <> <a href={c.href} class="rounded-sm transition-colors outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50">{c.name}</a> <svg aria-hidden="true" viewBox="0 0 16 16" class="size-3.5" fill="none" stroke="currentColor" stroke-width="1.5"><path d="m6 4 4 4-4 4" /></svg> </> )} </li> ); }) } </ol></nav>{schema && <JsonLd data={breadcrumbList(items, Astro.site ?? Astro.url)} />}More for navigation
- PaginationFreeNumbered pages with previous and next for an archive from paginate(). 36px controls, gaps as an ellipsis.Pagination.astro
- Table of contentsFreeOn this page: links to the h2 and h3 of an article, from Markdown headings or Portable Text.Toc.astro · headings.ts
- Skip linkFreeA link to the main content that appears on keyboard focus, as the first thing in the body.SkipLink.astro