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.jsonQuestions, answered
FaqSectionfaqPageJsonLddefaultFaqSectionLabels- +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
import { FaqSection, type FaqItem } from "@/components/sheenui/blocks/faq-section";
// Package build (after the first npm release, or a packed tarball): import { FaqSection, type FaqItem } from "@sheenui/theme";
const items: FaqItem[] = [
{ id: "license", question: "What licence is SheenUI under?", answer: "MIT. Copy the source and change whatever you need." },
{ id: "react", question: "Which React versions work?", answer: "React 19." },
{ id: "theme", question: "Can I change the colours?", answer: "Yes. Everything reads --sheen-* tokens." },
];
export function Example() {
return <FaqSection title="Questions, answered" items={items} defaultValue={["license"]} />;
}Files to copy
4 folders · 3 files · 3 packages
- From
theme/src/ blocks/faq-section.tsxcomponents/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.
import { FaqSection, faqPageJsonLd, type FaqItem } from "@/components/sheenui/blocks/faq-section";
// Package build (after the first npm release, or a packed tarball): import { FaqSection, faqPageJsonLd, type FaqItem } from "@sheenui/theme";
const items: FaqItem[] = [
{ id: "license", question: "What licence is SheenUI under?", answer: "MIT." },
{
id: "a11y",
question: "How accessible is it?",
answer: <p>Keyboard support, visible focus and a reduced-motion path.</p>,
answerText: "Keyboard support, visible focus and a reduced-motion path.",
},
];
export function Example() {
return (
<>
<script type="application/ld+json" dangerouslySetInnerHTML={{ __html: JSON.stringify(faqPageJsonLd(items)) }} />
<FaqSection
layout="split"
variant="separated"
title="Still curious?"
description="The short answers."
footer={<a href="https://example.com/contact">Ask us something else</a>}
items={items}
/>
</>
);
}Props
FaqSectionLabels keys and English defaults (1)
Keyboard
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
Related pages
20 blocks pages in all: browse them on All blocks.
By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .