ComponentsEditorial

Faq List

Always-open FAQ as a description list on Grid. Stack sets question and answer pairs in up to three columns; split rules the pairs apart and sets each question beside its answer when wide.

Open the preview in a new tab

The source comes with full access.

One payment of $149 opens the source right here and lets the CLI install every paid component, with lifetime updates.

Installation

pnpm dlx shadcn add @01orbital/faq-list
npx shadcn add @01orbital/faq-list
yarn shadcn add @01orbital/faq-list
bunx --bun shadcn add @01orbital/faq-list

Part of the 01orbital library. With a license, put ORBITAL_TOKEN in .env.local and the same command installs it (licensed install, pricing).

It lands at components/editorial/faq-list.tsx, as source you own and edit.

The example also uses heading and section. Install them too:

pnpm dlx shadcn add @01orbital/heading @01orbital/section
npx shadcn add @01orbital/heading @01orbital/section
yarn shadcn add @01orbital/heading @01orbital/section
bunx --bun shadcn add @01orbital/heading @01orbital/section

Usage

import {
  FaqList,
  FaqListAnswer,
  FaqListItem,
  FaqListQuestion,
} from "@/components/editorial/faq-list"
import { Heading } from "@/components/editorial/heading"
import {
  Section,
  SectionContent,
  SectionDescription,
  SectionHeader,
  SectionTitleGroup,
} from "@/components/editorial/section"

const COPY = {
  title: "Frequently asked questions",
  body: "The three things every team asks before installing.",
} as const

const FAQS = [
  {
    id: "install",
    question: "How do I install a block?",
    answer:
      "Run the command shown under the block. The CLI copies the source into your project.",
  },
  {
    id: "existing",
    question: "Does it fit an existing project?",
    answer: "Yes. It uses the same tokens and primitives as stock shadcn.",
  },
  {
    id: "license",
    question: "Can I use it for clients?",
    answer: "One license covers every project you build.",
  },
] as const

// Centred introduction over the columns; cols={2} is the two-column edition.
export default function FaqListDemo() {
  return (
    <Section>
      <SectionHeader align="center">
        <SectionTitleGroup>
          <Heading>{COPY.title}</Heading>
        </SectionTitleGroup>
        <SectionDescription>{COPY.body}</SectionDescription>
      </SectionHeader>
      <SectionContent>
        <FaqList cols={3}>
          {FAQS.map((faq) => (
            <FaqListItem key={faq.id}>
              <FaqListQuestion>{faq.question}</FaqListQuestion>
              <FaqListAnswer>{faq.answer}</FaqListAnswer>
            </FaqListItem>
          ))}
        </FaqList>
      </SectionContent>
    </Section>
  )
}

Anatomy

Faq List is built from 4 parts. In the example they nest like this:

FaqList
└─ FaqListItem
   ├─ FaqListQuestion
   └─ FaqListAnswer
  • FaqList: A list of questions and answers for an FAQ section, rendered as a <dl>. Put a FaqListItem inside for each question.
  • FaqListItem: One question and its answer inside FaqList. Put a FaqListQuestion and a FaqListAnswer inside.
  • FaqListQuestion: The question, as a <dt> in semibold text, inside FaqListItem.
  • FaqListAnswer: The answer, as a <dd> in muted text, inside FaqListItem. It can hold several paragraphs with a small gap between them. Links inside are underlined, and a <ul> inside gets bullets.

API reference

FaqList

A list of questions and answers for an FAQ section, rendered as a <dl>. Put a FaqListItem inside for each question.

stack (the default) sets the pairs in one to three columns. split puts a rule between pairs and, once the list is 48rem wide, sets each question beside its answer. className lands on the <dl>, but its columns follow the width of a wrapper around it, so to narrow the list, size its parent.

Prop

Type

It also accepts the HTML attributes of the element it renders.

FaqListItem

One question and its answer inside FaqList. Put a FaqListQuestion and a FaqListAnswer inside.

In a split list it pads its row and, once the list is 48rem wide, sets the question in a narrower column beside the answer.

It accepts the HTML attributes of the element it renders.

FaqListQuestion

The question, as a <dt> in semibold text, inside FaqListItem.

It accepts the HTML attributes of the element it renders.

FaqListAnswer

The answer, as a <dd> in muted text, inside FaqListItem. It can hold several paragraphs with a small gap between them. Links inside are underlined, and a <ul> inside gets bullets.

It accepts the HTML attributes of the element it renders.

Dependencies

npm: class-variance-authority, cn. The CLI installs them for you.

Registry pieces it installs with it:

  • grid

On this page