Skip to content

React FAQ Section

FaqSection is a React FAQ section block: a heading and an accordion of questions on glass whose closed answers open on find-in-page. faqPageJsonLd(items) returns the schema.org FAQPage object for the same questions.

npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/faq-section.json

Questions, answered

MIT. Copy the source into your project and change whatever you need.

  • FaqSection
  • faqPageJsonLd
  • defaultFaqSectionLabels
  • +1 more

Stacked

Press Ctrl or Cmd + F and search for 'Base UI': the closed answer opens. defaultValue opens an item at first; multiple lets several stay open.

Questions, answered

MIT. Copy the source into your project and change whatever you need.

Files to copy

4 folders · 3 files · 3 packages
From theme/src/
  • blocks/faq-section.tsx
  • components/accordion/
  • lib/{cn.ts, heading.ts}
  • styles/
shadcn CLI
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/faq-section.jsonRegistry item: faq-section. The styles need the Tailwind v4 glass UI setup.
Packages
pnpm add @base-ui/react clsx tailwind-merge

Split layout and structured data

layout='split' keeps the heading and a footer beside the list. faqPageJsonLd(items) returns the FAQPage object: render it into a script tag yourself (it never touches the document), and keep its text equal to what the page shows.

Still curious?

The short answers.

Props

PropTypeDefaultDescription
items (required)FaqItem[]NoneLists the questions, which render in the order given (FaqItem[]).
eyebrowReactNodeNoneShows a small label above the title (ReactNode).
titleReactNodeNoneSets the section heading (ReactNode).
descriptionReactNodeNoneSets the line under the heading (ReactNode).
footerReactNodeNoneContent under the heading or under the list, for a "still stuck?" line and a link (ReactNode).
layout"split" | "stacked""stacked""stacked" centers the heading above the list; "split" puts the heading and the footer beside the list on a wide block.
variant"glass" | "separated""glass"Surface of the list: "glass" is one glass card, "separated" gives each question its own card.
multiplebooleanfalseLet several answers be open at once (boolean).
valuestring[]NoneControls which items are open (string[] of item ids). Use with onValueChange.
defaultValuestring[]NoneThe items open at first when uncontrolled (string[]).
onValueChange((value: string[]) => void)NoneCalled with the open item ids whenever one opens or closes ((value: string[]) => void).
headingLevelHeadingLevelOption2Level of the section heading (1 to 6); the questions sit one level below. "none" renders plain text, no headings.
labelsPartial<FaqSectionLabels>defaultFaqSectionLabelsEvery other string, for translation: labels={{ region: "…" }}; omitted keys keep the English of defaultFaqSectionLabels. Its only key is listed in the key table under the props table.
classNamestringNoneAdds extra classes to the section (string).
FaqSectionLabels keys and English defaults (1)
Pass any key in labels; the rest keep the defaults of defaultFaqSectionLabels.
KeyEnglish default
regionFrequently asked questions

Keyboard

KeysAction
TabMove between the questions.
Enter/SpaceOpen or close the focused question.
Arrow Down/Arrow UpMove to the next or previous question.
Home/EndFirst or last question.

Accessibility

  • A <section> named by its heading; each question is a button inside a heading one level below it, with aria-expanded and aria-controls.
  • Closed answers use hidden='until-found', so the browser's find-in-page opens the matching one.
  • faqPageJsonLd only returns an object. Items whose answer is not a string and that have no answerText are left out, because JSON-LD answers are plain text.
  • The list is one glass card ('glass') or one card per question ('separated'); the open height animates in about 220 ms and is skipped under reduced motion.

All exports on this page

  • FaqSection — A frequently-asked-questions section: a heading and an accordion of questions in glass, with find-in-page that opens the matching answer.
  • defaultFaqSectionLabels — The English FaqSectionLabels used when labels is omitted; a partial labels prop is merged over it.
  • faqPageJsonLd — Builds the schema.org FAQPage JSON-LD object for a list of FAQ items, so search engines can read the same questions the page shows.

When to use the FAQ section

  • Use FaqSection near the pricing or the footer to answer objections in one place, with the first question open by default through defaultValue.
  • Use layout="split" on a wide page to keep the heading and a 'still stuck?' footer beside a long list, and variant="separated" when each question should be its own card.
  • Use faqPageJsonLd(items) to build the structured data for the same items, then render it into a script tag yourself; the helper only returns data and never touches the document.
  • Skip structured data for questions that are not visible on the page; search engines expect the JSON-LD text to match what the page shows.
  • Pair it with Pricing and ContactForm, and keep each answer short with a link to the docs for the long version.

Frequently asked questions

20 blocks pages in all: browse them on All blocks.

By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .