Accordion

Expandable sections with single or multiple open items.

Installation

Install with the CLI, or copy the component source into your project.

Add accordion (npm)

npx --yes -p github:itsvigneshv/default-file-ui#main df-ui add accordion

Default

Single open item with dividers inside a bordered card. The last row has no trailing divider.

Expandable sections for FAQs, release notes, and dense settings groups.
Use single mode for one open panel, or multiple mode when several answers can stay visible.
Triggers are buttons. Arrow keys, Home, and End move focus across enabled items.

Multiple

Keep several panels open at once with type multiple.

Starts open with gamma.
Toggle freely alongside other items.
Also starts open.

Non collapsible

With collapsible false, single mode always keeps one item open.

Clicking this trigger again will not close it while collapsible is false.
Opening this closes the previous item.

Leading icon

Pass any React node to leading on AccordionTrigger. Body text aligns under the title.

Pass any React node to leading. Icons, marks, or custom chrome all work.
Body text indents to sit under the title when a leading slot is present.
Swap the icon per item. There is no fixed icon set inside the component.
Use your own assets, kit icons, or any markup in the leading slot.

Title and subtitle

Add a secondary line under the title. Combine with leading and a custom indicator when needed.

Pair subtitle with leading and a custom indicator when the row needs more context.
Subtitle stays under the title and scales with the size prop.
Pass any React node to subtitle, including short helper copy.
Omit subtitle on any row that only needs a single title line.

Meta slot

Pass meta for dates or counts before the chevron.

Meta sits before the chevron for dates or counts.
Same pattern as the home updates list.

Sizes

Extra small, small, default, and large trigger density.

xs
Padding and type follow the size prop.
Compare density across sizes.
sm
Padding and type follow the size prop.
Compare density across sizes.
default
Padding and type follow the size prop.
Compare density across sizes.
lg
Padding and type follow the size prop.
Compare density across sizes.

Radius

Corner radius on the root. Default is 3xl. Pass none for square corners.

none
Pass radius to set the outer corner. Default is 3xl.
Use none for square corners.
md
Pass radius to set the outer corner. Default is 3xl.
Use none for square corners.
3xl
Pass radius to set the outer corner. Default is 3xl.
Use none for square corners.

Backgrounds

Shared header fill on every trigger, with a lighter panel fill on open items. Uses theme semantic colors so light and dark both stay readable. contentPadding insets the panel without changing regular accordion size padding.

Every header uses the same triggerBackground. Open panels use a lighter contentBackground.
Headers stay consistent. Only the expanded panel shifts to the lighter fill.

Separated

Disconnected cards with a gap between items. Each row owns its own border and radius.

Separated items sit in their own bordered cards with a gap between rows.
Dividers stay off by default. Pass showDividers to turn them back on.
Radius applies to each card. Pair with leading and a custom indicator as needed.
Use background tokens on the root or items when cards need a different fill.

Ghost

Flush embed with list dividers. Set showDividers to false for an unbroken list.

Ghost is a flush embed with list dividers between items.
Set showDividers to false when you want a fully unbroken list.

Disabled item

Disable a single item while leaving the rest interactive.

This item opens normally.
This body stays closed while disabled.

Controlled

Drive open state with value and onValueChange.

Open value: alpha

Controlled from React state.
onValueChange updates the parent.

Properties

Expandable sections for FAQs, changelogs, and settings groups. Compose Accordion, AccordionItem, AccordionTrigger, and AccordionContent. Supports single or multiple open items, sizes, dividers, and keyboard focus between triggers.

Accordion

PropTypeDefaultNotes
type"single" | "multiple""single"single opens one item at a time. multiple lets several items stay open.
collapsiblebooleantrueFor type single only. When true, clicking the open item closes it. When false, one item always stays open.
variant"default" | "ghost" | "separated""default"default is a connected list with dividers. ghost is a flush embed. separated renders each item as its own bordered card with a gap between rows (dividers off by default).
size"xs" | "sm" | "default" | "lg""default"Trigger padding and title or content type scale.
radius"none" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "full""3xl"Corner radius step on the root. Maps to a --radius-* token (default --radius-3xl). Steps scale from the project --radius set at create or init. Use none for square corners.
backgroundstring-Root shell fill. Prefer theme semantics such as var(--card). Sets --df-accordion-bg.
triggerBackgroundstring-Header fill for every trigger. Runs edge to edge on connected and ghost variants (inline padding lives on the trigger). Prefer theme semantics such as var(--muted) so light and dark stay readable. Absolute neutrals stay fixed and can break on dark surfaces. Sets --df-accordion-trigger-bg. Override per row with AccordionTrigger background.
contentBackgroundstring-Open panel fill for every item. Runs edge to edge on connected and ghost variants (inline padding lives on the content body). Prefer a theme-aware mix such as color-mix(in oklch, var(--muted) 40%, var(--card)). Absolute neutrals stay fixed and can break on dark surfaces. Sets --df-accordion-content-bg. Override per row with AccordionContent background.
contentPadding"none" | "sm" | "default" | "lg"-Block padding on open panels only. Omit to keep the size-based bottom padding used by regular accordions. Set when using contentBackground so filled panels can inset without changing default size spacing.
showDividersbooleantrue (false when variant is separated)Draw a hairline under each item. The last item never shows a trailing divider. Separated defaults to false unless you set this explicitly.
disabledbooleanfalseDisable every item in the accordion.
valuestring | null | string[]-Controlled open state. string or null for single; string array for multiple.
defaultValuestring | null | string[]-Uncontrolled initial open state.
onValueChange(value: string | null) => void | (value: string[]) => void-Called when open state changes.
classNamestring-Additional styles on the root.

AccordionItem

One expandable row. Owns the value shared by its trigger and content.

PropTypeDefaultNotes
valuestring-Unique item value (required).
disabledboolean-Non interactive item. Trigger stays closed.
idstring-Optional DOM id on the item wrapper.
classNamestring-Additional styles on the item.

AccordionTrigger

Button that toggles the item. Supports title, subtitle, meta, leading, and a custom indicator.

PropTypeDefaultNotes
childrenReactNode-Trigger title.
subtitleReactNode-Secondary line under the title. Pass text or any React node.
metaReactNode-Optional trailing metadata before the indicator (for example a date).
leadingReactNode-Optional leading icon or mark before the title. Pass any React node. When set, panel body text indents to align under the title.
indicatorReactNode | null-Replace the default chevron. Pass null to hide the indicator.
backgroundstring-Header fill for this trigger only. Prefer theme semantics such as var(--muted). Sets --df-accordion-trigger-bg on the button.
disabledboolean-Disable this trigger only.
classNamestring-Additional styles on the trigger button.

AccordionContent

Animated panel for the item body. Uses grid row expand and collapse with reduced motion support.

PropTypeDefaultNotes
childrenReactNode-Panel body.
backgroundstring-Panel fill for this content only. Prefer a theme-aware mix with var(--muted) and var(--card). Sets --df-accordion-content-bg on the panel.
forceMountbooleantrueKeep content mounted when closed so the height animation can run. Set false to unmount when closed.
classNamestring-Additional styles on the inner content.

Tokens

Theme defaults live on :root. Override these globally or on a local host.

TokenTypeDefaultNotes
--radiusCSS length0.625remBase corner radius from create or init (df-ui init --radius). Every --radius-* step derives from this value.
--radius-3xlCSS lengthcalc(var(--radius) * 2.2)Default radius step when radius is 3xl. The radius prop selects any --radius-* step from none to full.
--df-accordion-bgCSS colortransparentRoot shell fill. Set with the background prop or override on :root / the host.
--df-accordion-item-bgCSS colorvar(--card)Separated item card fill. Used when variant is separated.
--df-accordion-trigger-bgCSS colortransparentHeader (trigger) fill. Edge to edge on connected and ghost variants. Set with triggerBackground or AccordionTrigger background.
--df-accordion-content-bgCSS colortransparentOpen panel fill. Edge to edge on connected and ghost variants. Set with contentBackground or AccordionContent background.
--df-accordion-pad-inlineCSS lengthcalc(5 * var(--spacing-unit))Horizontal padding on triggers and content bodies for connected and ghost variants. Keeps fills full width while inseting text.
--df-accordion-content-pad-block-startCSS lengthcalc(5 * var(--spacing-unit))Top padding on open panel bodies when contentPadding is set.
--df-accordion-content-pad-block-endCSS lengthcalc(5 * var(--spacing-unit))Bottom padding on open panel bodies when contentPadding is set.
--df-accordion-radiusCSS length0Resolved corner radius from the radius prop. Applied to the root, or to each item when variant is separated.
--borderCSS colorvar(--df-neutral-100)Hairline color for item dividers when showDividers is true.
--df-duration-panelCSS time400msOpen and close duration for the panel and chevron.
--df-ease-decelerateCSS easingcubic-bezier(0.22, 1, 0.36, 1)Easing for the panel expand and chevron rotate.
--df-corner-shapeCSS corner-shapevar(--df-corner-shape-round)Theme corner curve for all kit chrome. round = circular arcs; smooth = continuous squircle. Set with df-ui init --corner-shape, or override on :root. Default round.