Skip to main content

FAQ Block

FAQ is an accordion-style frequently asked questions block built on MUI with a centered title, subtitle, and expandable question-and-answer items.

Installation

npm install @nodeblocks/frontend-faq-block

What You Need

ItemWhy it matters
faqTitlePrimary heading
subtitleSupporting line below the title
itemsQuestion-and-answer pairs rendered as accordion rows
Content lives in your app

FAQ manages accordion expand/collapse internally. Pass faqTitle, subtitle, and items from your page or CMS. Each item needs question and answer strings.

Code Examples

Live Editor
function Example() {
  const faqItems = [
    {
      question: 'What is this service?',
      answer:
        'This is a comprehensive platform designed to help you manage your business operations efficiently.',
    },
    {
      question: 'How do I get started?',
      answer:
        'Simply sign up for an account, complete your profile, and you can start using all the features immediately.',
    },
    {
      question: 'Is there a free trial?',
      answer: 'Yes, we offer a 14-day free trial with full access to all features. No credit card required.',
    },
    {
      question: 'How can I contact support?',
      answer:
        'You can reach our support team through email, live chat, or by calling our support hotline during business hours.',
    },
  ];

  return (
    <FAQ
      faqTitle="Frequently Asked Questions"
      subtitle="Find answers to the most common questions about our service"
      items={faqItems}
    />
  );
}
Result
Loading...

Important Props

Core Props

PropTypeRequiredDefaultDescription
faqTitleReactNodeYesPrimary heading rendered by FAQ.Title
subtitleReactNodeYesSupporting line below the title
items{ question: string; answer: string }[]YesFAQ entries mapped to accordion rows in FAQ.ItemList

Layout and Composition Props

PropTypeRequiredDefaultDescription
childrenReactNode | functionNoundefinedCompound sub-components (FAQ.Title, FAQ.ItemList) or a function ({ defaultBlocks, defaultBlockOrder }) => ({ blocks, blockOrder }) to inject or reorder layout blocks
classNamestringNoundefinedClass name on the root stack (nbb-faq)
sxSxPropsNoundefinedMUI system styles for the root stack
spacingStackProps['spacing']No{ xs: 5, sm: 6 }Vertical spacing on the root stack

FAQ inherits StackProps (except children). Default defaultBlockOrder: title, item, itemList.

Sub-component props

Sub-components read from context and accept the same content keys as props to override locally.

Sub-componentMain PropsInheritsBuilt on
FAQ.TitlefaqTitle, subtitle, children, spacing (default 1), className, sxStackPropsStack + Typography
FAQ.ItemListitems, activeIndex, toggleAccordion, children, className, sxStackPropsStack + Divider + FAQ.Item rows
FAQ.Itemquestion, answer, index, isActive, onToggle, className, sxAccordionPropsAccordion + AccordionSummary + AccordionDetails + ExpandMore icon

Default UI Blocks

BlockBuilt onNotes
FAQ (root)StackColumn layout with responsive spacing (nbb-faq)
title (FAQ.Title)Stack + TypographyCentered title (variant="h6" / responsive h4) and subtitle (variant="h1")
itemList (FAQ.ItemList)Stack + DividerMaps items to FAQ.Item accordions with dividers above and below
item (FAQ.Item)AccordionSingle row with Q. prefix, bold question, and answer body

Default root render order: titleitemList.

TypeScript

import * as React from 'react';
import { FAQ } from '@nodeblocks/frontend-faq-block';
import type { ReactNode } from 'react';

type FaqItem = {
question: string;
answer: string;
};

type FaqSectionProps = {
faqTitle: ReactNode;
subtitle: ReactNode;
items: FaqItem[];
};

export function FaqSection({ faqTitle, subtitle, items }: FaqSectionProps) {
return <FAQ faqTitle={faqTitle} subtitle={subtitle} items={items} />;
}