FAQ: two-column exclusive accordion
Heading and support link on the left, an exclusive animated accordion of questions on the right, built on native details.
pnpm dlx shadcn@latest add @haze/faq-accordion---
import Accordion from "../ui/accordion.astro";
interface Props {
title?: string;
description?: string;
/** Target of the "Contact support" link. Pass an empty string to hide the link. */
contactHref?: string;
/** Shared name makes the accordion exclusive (one item open at a time). Set a unique value per FAQ on the page. */
groupName?: string;
items?: { question: string; answer: string }[];
}
const {
title = "Frequently asked questions",
description = "Can't find what you're looking for?",
contactHref = "#contact",
groupName = "haze-faq",
items = [
{ question: "Can I import my data from another tool?", answer: "Yes. Importers for the most common issue trackers bring over issues, comments, labels and assignees. Most workspaces finish importing in under five minutes." },
{ question: "Is there a free plan?", answer: "The Free plan covers up to three members with unlimited issues. You only pay when the team grows or you need automations." },
{ question: "How does billing work for new members?", answer: "Members are billed pro rata from the day they join. Removing someone credits the unused time to your next invoice." },
{ question: "Where is my data stored?", answer: "In the EU or the US, chosen when you create the workspace. All data is encrypted at rest and in transit." },
{ question: "Do you offer discounts for non-profits?", answer: "Registered non-profits and open-source projects get the Team plan at half price. Contact us with proof of status." },
],
} = Astro.props;
const accordionItems = items.map((item) => ({ title: item.question, content: item.answer }));
---
<section aria-labelledby="faq-accordion-title" class="bg-background px-6 py-20 sm:py-24">
<div class="mx-auto grid max-w-6xl gap-10 lg:grid-cols-[1fr_2fr] lg:gap-16">
<div>
<h2 id="faq-accordion-title" class="text-3xl/9 font-semibold tracking-tight text-balance text-foreground sm:text-4xl/11">{title}</h2>
<p class="mt-4 text-base/7 text-pretty text-muted-foreground">
{description}
{
contactHref && (
<>
<a href={contactHref} class="rounded-sm font-medium text-foreground underline underline-offset-4 transition-colors duration-150 ease-snappy hover:text-foreground/80 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring">Contact support</a>.
</>
)
}
</p>
</div>
<Accordion items={accordionItems} name={groupName} variant="plain" icon="plus" />
</div>
</section>When to use
- Answering five to ten pre-sales or billing questions
- You need an accordion with zero JavaScript
When not to use
- Answers are long articles; link to a help center instead
- Users need to compare all answers at once; show them expanded
Installation
Add the Haze registry to components.json once, then install FAQ: two-column exclusive accordion with the shadcn CLI. Works in any Astro project with Tailwind CSS v4.
pnpm dlx shadcn@latest add @haze/faq-accordionnpx shadcn@latest add @haze/faq-accordionyarn dlx shadcn@latest add @haze/faq-accordionbunx --bun shadcn@latest add @haze/faq-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 |
|---|---|---|---|
| title | string | "Frequently asked questions" | Section heading (h2). |
| description | string | demo copy | Text before the support link. |
| contactHref | string | "#contact" | Target of the Contact support link. |
| groupName | string | "haze-faq" | Shared details name; makes only one item open at a time. |
| items | { question: string; answer: string }[] | 5 demo questions | Questions and answers. |
Keyboard interactions
- EnterSpace
- Open or close the focused question
Accessibility
- Native <details>/<summary> gives button semantics and expanded state without ARIA.
- Answers stay in the DOM, so in-page search can find and open them in supporting browsers.
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 "FAQ: two-column exclusive accordion" with `npx shadcn@latest add @haze/faq-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 FaqAccordion from "@/components/haze/blocks/faq-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/faq-accordion.md
Customize with real content
Adapt the Haze faq-accordion block for our product. Replace the demo values of these props with our real content: title, description, contactHref, groupName, items. Keep the layout, the heading level rules and these accessibility details: Native <details>/<summary> gives button semantics and expanded state without ARIA. Answers stay in the DOM, so in-page search can find and open them in supporting browsers. Do not add raw color classes; use the Haze tokens.
Choose the right block
Before using faq-accordion, check it fits: use it when answering five to ten pre-sales or billing questions; you need an accordion with zero javascript. Avoid it when answers are long articles; link to a help center instead; users need to compare all answers at once; show them expanded.
Dependencies
- @haze/accordion
- @haze/theme (one-time setup)
Source · Original Haze UI work.