Marketing sectionsFaq
Searchastronomic.dev# Faq
To build your own questions layout: a section heading and questions that each open on their own. For a ready layout, use FaqList or FaqSplit.
Static: no JavaScript.
## Usage
```astro
import Faq from "@astronomic/ui-pro/components/Faq.astro";
```
## Examples
### Slots
The section is a shell: the eyebrow, the heading and the text always show in that order, then the questions in the default slot, one FaqItem each. The shell sets the type and the gaps; the recipes lay out the questions. FaqList and FaqSplit are recipes built on it. childHeadingTag() in lib/heading.ts gives the questions' level.
```astro
---
import Badge from "@astronomic-dev/ui/components/Badge.astro";
import { childHeadingTag } from "@astronomic-dev/ui/lib/heading.ts";
import Faq from "@astronomic/ui-pro/components/Faq.astro";
import FaqItem from "@astronomic/ui-pro/components/FaqItem.astro";
const heading = "Questions";
// One level under the section heading: h2 gives h3.
const tag = childHeadingTag({ heading });
---
<div class="mx-auto max-w-3xl px-6 py-16">
<Faq heading={heading} text="What firms ask us before a first call.">
<Badge slot="eyebrow">Help</Badge>
<FaqItem question="How long does a project take?" answer="Most sites take six to ten weeks from the first call to launch." headingTag={tag} open />
<FaqItem question="Can our team edit the site after launch?" answer="Yes. Every page is built for your team to edit, and we train them before the handover." headingTag={tag} />
</Faq>
</div>
```
## Props
### Faq
| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `heading` | `string` | None | The section heading, in the title role in display type. Without it there is no section and no header: a plain <div> holds only the questions. |
| `emphasis` | `boolean` | `false` | Turn one *phrase* in the heading into <em>: exactly two asterisks around text with no space inside, as in "Built for *the long run*". Any other asterisks show as typed. Off by default, so the heading shows as typed. How the <em> looks is the theme's. |
| `mark` | `string` | None | A short mark after the heading, such as "(12)" or "©2026", in small muted type. It sits beside the heading, outside it, so the heading's name stays plain. Shown only with a heading. |
| `markLabel` | `string` | None | What the mark says to a screen reader, such as "12 projects": the mark is then hidden from screen readers and this is read in its place. Without it, the mark is read as written. |
| `text` | `string` | None | One or two sentences under the heading, in the lead role, muted. Shown only with a heading. |
| `headingTag` | `"h2" \| "h3" \| "h4"` | `"h2"` | The heading element. Questions sit one level under it. |
| `align` | `"start" \| "center"` | `"start"` | For recipes. The alignment of the header (SectionHead) only: the recipe lays out the questions. |
| `contentClass` | `string` | None | For recipes. Classes for the row that holds the header and the questions, such as FaqSplit's two columns. |
| `headerClass` | `string` | None | For recipes. Classes for the header (the eyebrow, the heading and the text), such as FaqSplit's sticky header. |
| `listClass` | `string` | None | For recipes. Classes for the box that holds the questions (a <div>: the questions are <details>, not list items). It sits inside the faq container, so its classes can query it (@3xl/faq:...). |
| `class` | `string` | None | More classes for the root (the <section>, or the <div> without a heading), merged with cn(), so yours win on conflicts. The root is a named size container (inline-size containment): in a shrink-to-fit parent (inline-flex, a float, fit-content) it collapses, so give it a width there. |
| Slot | Description |
| --- | --- |
| `eyebrow` | A short line above the heading, such as a Badge. Shown only with a heading. |
| `default` | The questions: one FaqItem each. Pass each its headingTag, and the same name to every one for one open at a time. |
Any other attribute goes on the <section>, or on the <div> without a heading.
## Accessibility
- With a heading, renders a <section> named by it, so it is a region landmark. The heading id is unique on the page.
- Without a heading, renders a plain <div>. Put your own heading above it.
- Each question is a native <details> and <summary>, so the keyboard and screen readers work without any script: Enter or Space opens and closes it.
- Each question sits one level under the section heading (h2 gives h3), so the questions are easy to skim by heading. With no heading, it is an h3 unless you set itemHeadingTag.
- Do not put links or other controls in a question: the whole summary is the control.
- Safari with VoiceOver reads a summary as one button and may flatten what is inside it, so the question headings may not show in its heading list. The questions are still reached as buttons. If heading navigation matters there, give the section a heading.
- With single, opening a question closes the others in the same list (the browser does it); in browsers without it, several stay open.
Faq
ProTo build your own questions layout: a section heading and questions that each open on their own. For a ready layout, use FaqList or FaqSplit.
- File
- Faq.astro
- Group
- Marketing sections
- Kind
- Static: no JavaScript
- Examples
- 1
Examples
Drag the orange handle to set the width. Frames get real breakpoints.
- Static
- Interactive
- Framed
Slots
The section is a shell: the eyebrow, the heading and the text always show in that order, then the questions in the default slot, one FaqItem each. The shell sets the type and the gaps; the recipes lay out the questions. FaqList and FaqSplit are recipes built on it. childHeadingTag() in lib/heading.ts gives the questions' level.
This preview did not load.
main.astro
examples/faq/main.astro
---
import Badge from "@astronomic-dev/ui/components/Badge.astro";
import { childHeadingTag } from "@astronomic-dev/ui/lib/heading.ts";
import Faq from "@astronomic/ui-pro/components/Faq.astro";
import FaqItem from "@astronomic/ui-pro/components/FaqItem.astro";
const heading = "Questions";
// One level under the section heading: h2 gives h3.
const tag = childHeadingTag({ heading });
---
<div class="mx-auto max-w-3xl px-6 py-16">
<Faq heading={heading} text="What firms ask us before a first call.">
<Badge slot="eyebrow">Help</Badge>
<FaqItem question="How long does a project take?" answer="Most sites take six to ten weeks from the first call to launch." headingTag={tag} open />
<FaqItem question="Can our team edit the site after launch?" answer="Yes. Every page is built for your team to edit, and we train them before the handover." headingTag={tag} />
</Faq>
</div>Minimal · Light