Accordion

Show and hide long optional content.

$ npx shadcn@latest add https://mahrdesign.faizintifada.com/r/accordion.json

FAQ (single)

Default type="single": opening a question closes the open one. Header 56, title 16/600, chevron 20.

Slip terbit pada hari gaji dibayar, setiap tanggal 25. Jika tanggal 25 jatuh pada akhir pekan atau hari libur, gaji dan slip terbit pada hari kerja sebelumnya. Desember 2026: Kamis, 24 Des.

Multiple open, disabled item

type="multiple": each item opens on its own. A disabled item is 60 % and does not react.

Telepon, alamat dan kontak darurat. Data lain diatur oleh HR.

Surat dokter dalam PDF atau JPG, paling besar 2 MB.

Inside the payslip

"Rincian potongan": optional detail, closed by default; the total stays visible in the header.

When to use

  • Long optional content the user reads only when needed: the Bantuan FAQ, "Rincian potongan" on the slip.
  • A list of questions where seeing all the headings at once helps the user find theirs.

When not to use

  • Required form fields → show them; never hide what the user must fill in.
  • Switching between two or more views → SegmentedControl.
  • One short note or warning → Callout.
  • Many records → Table or a Card with ListRows.
  • An accordion inside an accordion → never; split the content into separate cards.

Which one?

Must the user fill in or act on the content?├─ Yes → do not hide it. Show it in the form or card.└─ No   Is it one short note?   ├─ Yes → Callout   └─ No      Should only one section be open at a time (FAQ)?      ├─ Yes → <Accordion> (type="single", default)      └─ No  → <Accordion type="multiple">

Do and don't

DoWrite each header as the user's question"Kapan slip gaji terbit?" lets the user scan for their question before they open anything.
Don'tHide required fields in an accordionA closed "Data rekening" section in a form hides fields the user must fill in; they miss them and the form fails.

Installation

Add Accordion with the shadcn CLI (your project needs a components.json and the MaHR theme: https://mahrdesign.faizintifada.com/r/theme.json), or copy the files by hand.

terminal
bunx --bun shadcn@latest add https://mahrdesign.faizintifada.com/r/accordion.json

API

import { Accordion, AccordionItem, AccordionTrigger, AccordionPanel } from "@/components/ui/accordion"
PropTypeDefaultDescription
type"single" | "multiple""single"Closed set. single = one item open at a time.
value · defaultValue · onValueChangeany[] · (value) => void–Open item values (Base UI Accordion.Root).
AccordionItem valueany–Unique per item.
AccordionItem disabledbooleanfalse60 %, header does not react.
AccordionTrigger childrenReactNode–The header text, 16/600. Write it as the user's question.
AccordionPanel children · classNameReactNode · string–Body 16/24 muted; padding is on an inner element (never on the 0fr track). className goes to that inner element.
Motion––transitions.dev 21: grid-rows 0fr↔1fr 250 ms both ways, ease-smooth-out, inner fade + 2 px unblur, chevron scaleY flip. Reduced motion: no transition.