Updated
Folder FAQ
Customize
Cascade
Peek64px
Tab width132px
Lift6px
Radius16px
Medium
Default open0
Installation
npx shadcn@latest add https://uibrik.com/r/folder-faq.jsonInstall the packages
npm install @tabler/icons-react motionAdd the cn helper
Imports
cnfrom@/lib/utils, whichshadcn initcreates. Add it by hand without shadcn.Copy the source into your project
components/uibrik/folder-faq/folder-faq.tsx"use client"; import { useEffect, useId, useRef, useState, type CSSProperties, type KeyboardEvent } from "react"; import { motion, useReducedMotion } from "motion/react"; import { IconPlus } from "@tabler/icons-react"; import { cn } from "@/lib/utils"; // Folder FAQ. Questions are files in a drawer, seen from the front: each one's // tab and the strip below it peek out above the folder in front. Opening one // lifts it a little out of the stack and slides every folder in front of it // down, so the answer is uncovered rather than unfolded. // // With `sheet`, the answer is printed on a page inside the folder: it rises a // little as the folder opens and its foot stays tucked behind the folder in // front, like paper pulled partway out of a file. // // Each folder is a tab and a body painted the same colour, with the outline // drawn by drop-shadow filters so the two read as one silhouette, concave // shoulders included. const TAB_H = 28; // height of a tab, px // Text sizes; the answer's line height also spaces the ruled lines. const SIZES = {
Adds the files to
components/uibrik/folder-faq and installs @tabler/icons-react and motion. With the @uibrik namespace set up: npx shadcn@latest add @uibrik/folder-faq.Usage
import { FolderFaq } from "@/components/uibrik/folder-faq/folder-faq";const items = [ { label: "Start", question: "What do I get with a free account?", answer: "Every component, the source for each one, and updates as new ones land. Pro adds the full templates and priority support." }, { label: "Install", question: "How do I add a component to my project?", answer: "Copy the file into your codebase, or run the add command from its page. Components only depend on Motion and Tailwind." }, // …4 more];<FolderFaq items={items} tabLayout="cascade" peek={64} tabWidth={132} lift={6} radius={16} sheet ruled size="md" defaultOpen={0}/>Where to use Folder FAQ
Distinctive FAQ sections
Questions peeking out on folder tabs make a help section stand out from standard accordions.
Pairs with Accordion
Document product help
A drawer of files fits help centres for storage, docs and file-sharing products.
Pairs with Folder Peek
Case study details
Lifting one file from the stack works for project notes and supporting details.
Props
FolderFaq- tabLayout
- Type "cascade" | "alternate" | "left"
- "cascade"
- Where the tabs sit: stepping across in threes, swapping sides, or all on the left.
- peek
- Type number
- 64
- How much of each folder shows above the one in front, tab included.
- tabWidth
- Type number
- 132
- Width of a tab.
- lift
- Type number
- 6
- How far the open folder rises out of the stack.
- radius
- Type number
- 16
- Corner radius of a folder.
- sheet
- Type boolean
- true
- Print the answer on a sheet of paper that rises out of the folder, its foot tucked behind the one in front.
- ruled
- Type boolean
- true
- Faint ruled lines on the sheet.
- size
- Type "md" | "lg"
- "md"
- Text size of tabs, questions and answers.
- defaultOpen
- Type number
- 0
- Folder open on mount, or -1 for none.
- itemsrequired
- Type { question: string; answer: string; label?: string }[]
- –
- Questions, front of the drawer last. The label goes on the tab and defaults to the folder's number.
- className
- Type string
- –
- Classes for the wrapper.