FAQ

A run of questions, one open at a time, separated by rules.

Installation

$
npx shadcn@latest add https://ui.mattdowney.com/r/faq.json

Usage

import { Faq, FaqItem, FaqQuestion, FaqAnswer } from "@/components/ui/faq"

Examples

Default

One answer is open at a time, and clicking the open question closes it. Items are divided by a rule rather than each sitting in its own box: a FAQ is one block with several parts, not several blocks. A stack of Collapsibles is the other shape, and it is the right one when several disclosures should be open together.

Point the shadcn CLI at the component’s registry URL. The source lands in your project as editable code, with no package to keep in sync.

Rich answers

An answer holds paragraphs, lists, and links. The kit's inline-link rule is applied by the component, so an anchor is never styled at the call site; a control that is not an anchor opts in with data-inline-link and reads as part of the sentence.

API Reference

PropTypeDefaultDescription
valueFaqstring | nullNoneThe open item's value, for a controlled block. Omit to leave it uncontrolled.
defaultValueFaqstring | nullNoneThe item open on mount. Opening one keeps the block from reading as inert.
onValueChangeFaq(value: string | null) => voidNoneCalled with the newly open item, or null when the open one is closed.
value*FaqItemstringNoneIdentifies the item. Must be unique within the block.
levelFaqQuestion2 | 3 | 4 | 5 | 63Heading rank, so a page of these has a real outline. 3 sits under a section h2; use 2 when the FAQ is its own section under the h1.
disabledFaqItembooleanfalseDisables the item; the question dims and stops responding.
valueFaqstring | nullThe open item's value, for a controlled block. Omit to leave it uncontrolled.
defaultValueFaqstring | nullThe item open on mount. Opening one keeps the block from reading as inert.
onValueChangeFaq(value: string | null) => voidCalled with the newly open item, or null when the open one is closed.
value*FaqItemstringIdentifies the item. Must be unique within the block.
levelFaqQuestion2 | 3 | 4 | 5 | 6 = 3Heading rank, so a page of these has a real outline. 3 sits under a section h2; use 2 when the FAQ is its own section under the h1.
disabledFaqItemboolean = falseDisables the item; the question dims and stops responding.