Accordion
Show and hide long optional content.
$ npx shadcn@latest add https://mahrdesign.faizintifada.com/r/accordion.jsonFAQ (single)
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
Telepon, alamat dan kontak darurat. Data lain diatur oleh HR.
Surat dokter dalam PDF atau JPG, paling besar 2 MB.
Inside the payslip
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?
Do and don't
Write each header as the user's question"Kapan slip gaji terbit?" lets the user scan for their question before they open anything.
Hide 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.
API
import { Accordion, AccordionItem, AccordionTrigger, AccordionPanel } from "@/components/ui/accordion"| Prop | Type | Default | Description |
|---|---|---|---|
type | "single" | "multiple" | "single" | Closed set. single = one item open at a time. |
value · defaultValue · onValueChange | any[] · (value) => void | – | Open item values (Base UI Accordion.Root). |
AccordionItem value | any | – | Unique per item. |
AccordionItem disabled | boolean | false | 60 %, header does not react. |
AccordionTrigger children | ReactNode | – | The header text, 16/600. Write it as the user's question. |
AccordionPanel children · className | ReactNode · 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. |