Footer with collapsible sitemap
Sitemap footer with visible link columns on desktop and expandable groups on smaller screens.
pnpm dlx shadcn@latest add @haze/footer-accordion---
import { ArrowUp, ChevronDown } from "@lucide/astro";
import { cn } from "../../../lib/haze/utils";
import LogoMark from "../ui/logo-mark.astro";
interface Link { label: string; href: string; current?: boolean }
interface Group { title: string; links: Link[] }
interface Props {
brand?: string;
homeHref?: string;
tagline?: string;
groups?: Group[];
legal?: Link[];
navLabel?: string;
legalLabel?: string;
backToTop?: Link | null;
copyright?: string;
class?: string;
}
const {
brand = "Fieldwork",
homeHref = "/",
tagline = "A library for building thoughtful web interfaces.",
groups = [
{ title: "Library", links: [
{ label: "UI components", href: "/browse?kind=ui" },
{ label: "Page blocks", href: "/browse?kind=block" },
{ label: "All patterns", href: "/browse/" },
] },
{ title: "Resources", links: [
{ label: "Quickstart", href: "/docs/" },
{ label: "What’s new", href: "/browse?cat=changelog" },
{ label: "FAQ patterns", href: "/browse?cat=faq" },
] },
{ title: "Explore", links: [
{ label: "Forms", href: "/browse?cat=forms" },
{ label: "Navigation", href: "/browse?cat=navigation" },
{ label: "Layout and media", href: "/browse?cat=layout" },
] },
],
legal = [{ label: "License and usage", href: "/docs/" }],
navLabel = "Sitemap",
legalLabel = "Legal",
backToTop = { label: "Back to top", href: "#" },
copyright = "© 2026 Fieldwork",
class: className,
} = Astro.props;
const linkClass = "inline-flex min-h-8 max-w-full items-center rounded-sm text-sm/5 wrap-anywhere text-muted-foreground transition-colors duration-150 hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring aria-[current=page]:font-semibold aria-[current=page]:text-foreground";
---
<footer class={cn("border-t border-border bg-muted/40 px-4 pt-8 pb-5 sm:px-6 sm:pt-12", className)}>
<div class="mx-auto max-w-6xl">
<div class="grid gap-6 lg:grid-cols-[minmax(0,15rem)_minmax(0,1fr)] lg:gap-12">
<div class="min-w-0 wrap-anywhere">
<a href={homeHref} aria-label={`${brand} home`} class="inline-flex min-h-8 items-center rounded-md focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring">
<LogoMark name={brand} shape="square" class="text-foreground [&_svg]:shrink-0" />
</a>
<p class="mt-2 max-w-xs text-sm/6 text-muted-foreground">{tagline}</p>
</div>
{groups.length > 0 && (
<nav aria-label={navLabel} class="min-w-0">
<div class="grid border-y border-border lg:hidden">
{groups.map((group) => (
<details class="group border-b border-border last:border-b-0">
<summary class="flex min-h-11 cursor-pointer list-none items-center justify-between gap-3 rounded-md px-1 py-2 text-sm/5 font-medium wrap-anywhere focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring [&::-webkit-details-marker]:hidden">
{group.title}
<ChevronDown class="size-4 shrink-0 text-muted-foreground transition-[rotate] duration-200 ease-snappy group-open:rotate-180" aria-hidden="true" />
</summary>
<ul role="list" class="grid gap-0.5 px-1 pb-2">
{group.links.map((link) => <li><a href={link.href} aria-current={link.current ? "page" : undefined} class={linkClass}>{link.label}</a></li>)}
</ul>
</details>
))}
</div>
<div class="hidden gap-x-8 gap-y-6 lg:grid lg:grid-cols-[repeat(auto-fit,minmax(min(100%,9rem),1fr))]">
{groups.map((group) => (
<div class="min-w-0">
<p class="mb-2 text-sm/5 font-semibold wrap-anywhere">{group.title}</p>
<ul role="list" class="grid gap-0.5">
{group.links.map((link) => <li><a href={link.href} aria-current={link.current ? "page" : undefined} class={linkClass}>{link.label}</a></li>)}
</ul>
</div>
))}
</div>
</nav>
)}
</div>
<div class="mt-5 flex flex-wrap items-center justify-between gap-x-5 gap-y-2 lg:mt-8 lg:border-t lg:border-border lg:pt-4">
<p class="text-[0.8125rem]/5 wrap-anywhere text-muted-foreground">{copyright}</p>
{legal.length > 0 && (
<nav aria-label={legalLabel}>
<ul role="list" class="flex flex-wrap gap-x-4">
{legal.map((link) => <li><a href={link.href} class={cn(linkClass, "text-[0.8125rem]/5")}>{link.label}</a></li>)}
</ul>
</nav>
)}
{backToTop && <a href={backToTop.href} class={cn(linkClass, "gap-1.5 text-[0.8125rem]/5")}><ArrowUp class="size-3.5 shrink-0" aria-hidden="true" />{backToTop.label}</a>}
</div>
</div>
</footer>When to use
- A long footer needs to stay compact on phones
- Visitors use the footer to jump into another part of the site
When not to use
- The site has only a handful of secondary links. Use footer-compact.
- The main footer action is signing up for updates. Use footer-newsletter.
Installation
Add the Haze registry to components.json once, then install Footer with collapsible sitemap with the shadcn CLI. Works in any Astro project with Tailwind CSS v4.
pnpm dlx shadcn@latest add @haze/footer-accordionnpx shadcn@latest add @haze/footer-accordionyarn dlx shadcn@latest add @haze/footer-accordionbunx --bun shadcn@latest add @haze/footer-accordionFirst time? Registry and theme setup
1. Add to components.json:
{
"registries": {
"@haze": "http://localhost:4329/r/{name}.json"
}
}2. Install the theme once: npx shadcn@latest add @haze/theme, then import it after Tailwind in your global CSS:@import "./haze.css";
API reference
| Prop | Type | Default | Description |
|---|---|---|---|
| brand | string | "Fieldwork" | Wordmark text. |
| homeHref | string | "/" | Destination of the linked wordmark. |
| tagline | string | Demo description | Short supporting copy under the wordmark. |
| groups | { title: string; links: Link[] }[] | Library, Resources, Explore | Named sections of sitemap links. Links accept an optional current flag. |
| legal | Link[] | License and usage | Links in the legal row. |
| navLabel | string | "Sitemap" | Accessible name for the sitemap landmark. |
| legalLabel | string | "Legal" | Accessible name for the legal landmark. |
| backToTop | Link | null | { label: "Back to top", href: "#" } | Link to the top of the page. Pass null to omit it. |
| copyright | string | "© 2026 Fieldwork" | Copyright or attribution text. |
| class | string | – | Additional classes on the footer. |
Keyboard interactions
- EnterSpace
- Toggle the focused footer section on small screens.
- Tab
- Move through the visible sitemap and legal links.
Accessibility
- Native disclosures expose their open state and hide their links until expanded.
- Only one sitemap presentation is visible and keyboard reachable at each width.
Notes for AI
Copy into Claude Code, Cursor, Codex or any coding agent. Agents can also read the Markdown version of this page.
Install and use
Install the Haze UI block "Footer with collapsible sitemap" with `npx shadcn@latest add @haze/footer-accordion`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "http://localhost:4329/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import FooterAccordion from "@/components/haze/blocks/footer-accordion.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: http://localhost:4329/blocks/footer-accordion.md
Customize with real content
Adapt the Haze footer-accordion block for our product. Replace the demo values of these props with our real content: brand, homeHref, tagline, groups, legal, navLabel, legalLabel, backToTop, copyright, class. Keep the layout, the heading level rules and these accessibility details: Native disclosures expose their open state and hide their links until expanded. Only one sitemap presentation is visible and keyboard reachable at each width. Do not add raw color classes; use the Haze tokens.
Choose the right block
Before using footer-accordion, check it fits: use it when a long footer needs to stay compact on phones; visitors use the footer to jump into another part of the site. Avoid it when the site has only a handful of secondary links. use footer-compact.; the main footer action is signing up for updates. use footer-newsletter.. Alternatives: @haze/footer-columns, @haze/footer-compact, @haze/footer-newsletter.
Dependencies
- npm: @lucide/astro
- @haze/logo-mark
- @haze/utils
- @haze/theme (one-time setup)
Source · Original Haze UI work.