FAQ
Group frequently asked questions in an accordion that keeps one answer open at a time.
- Introduced
- v0.4.0
- Supported through
- Latest
Follow the quickstart guide to create your first documentation site. Write your pages in Markdown or MDX.
Yes. Add Code Altas to your Next.js project and point it at your documentation directory.
Each FAQ keeps at most one answer open. Opening another question closes the previous answer. Click the open question again to collapse it.
<FAQ>
<Question icon="lucide:rocket" title="How do I get started?" defaultOpen>
Follow the quickstart guide to create your first documentation site.
</Question>
<Question icon="simple:github" title="Can I use my existing repository?">
Yes. Add Code Altas to your Next.js project.
</Question>
<Question title="Can I open several answers at once?">
Opening another question automatically closes the previous answer.
</Question>
</FAQ>FAQ and Question are available automatically in MDX. In a React Server Component, import them from @code-altas/ui:
import { FAQ, Question } from "@code-altas/ui"Behavior
- Place
Questioncomponents directly insideFAQ. React fragments are supported; arbitrary wrappers are not. RenderingQuestionindependently throws an error. - Set
defaultOpenon at most one question per FAQ. Multiple defaults throw an error instead of silently choosing an answer. - Without
defaultOpen, all answers start collapsed. This prop only sets the initial state. - Opening a question closes the previously open answer. Clicking an open question closes it, so all answers can be collapsed.
- Separate FAQ groups manage their state independently.
- Use Tab and Shift + Tab to focus question buttons, then Enter or Space to expand or collapse an answer.
Answer content and icons
Answers accept Markdown and MDX, including lists, links, code blocks, and other components. Leave blank lines around Markdown inside Question to ensure it is parsed correctly.
icon is optional and uses the same icon names as other components, such as lucide:rocket or simple:github. Questions without an icon retain the same layout and interaction.
Props
| Property | Type | Default | Description |
|---|---|---|---|
children | React.ReactNode | - | Question components. Fragments and conditional children are supported. An empty FAQ renders nothing. |
className | string | - | Additional CSS classes for the FAQ container. |
| Property | Type | Default | Description |
|---|---|---|---|
title | string | - | Required question title, displayed in the expand/collapse button. |
icon | string | - | Optional icon name, such as lucide:rocket or simple:github. |
defaultOpen | boolean | | Whether this answer starts open. At most one Question per FAQ may enable it. |
children | React.ReactNode | - | Answer content. Supports Markdown and MDX components. |

