Skip to content
Hazine

Multi-Open Accordion with Controls

Accordion where any number of sections stay open, under a toolbar with Expand all, Collapse all and a running open count. Use it to fold a long record into titled field groups.

How it differs. Independent panels under a group toolbar: bulk buttons go inert when they would do nothing, the open set is controllable for deep links, and a panel can render its fields as a description list.

Install

pnpm dlx shadcn@latest add @hazine/accordion-multi-open-controls

Adds 1 file, 1 shadcn primitive (button), 2 Hazine items (@hazine/heading, @hazine/use-controllable-state), and 2 packages (lucide-react, class-variance-authority).

First time? Add the registry to components.json
{
  "registries": {
    "@hazine": "https://api.hazine.dev/r/{name}.json"
  }
}

Needed once per project. Items resolve each other through the @hazine namespace.

Props13

itemsrequired
AccordionSection[]
value
string[]
Values of the open sections, in the order of `items`.
defaultValue
string[]
onValueChange
(value: string[]) => void
headingLevel
HeadingLevel = 3
Rank of every section header.
controlsLabel
string = "Section controls"
Accessible name of the toolbar that holds the two bulk buttons.
expandLabel
string = "Expand all"
collapseLabel
string = "Collapse all"
formatCount
(open: number, total: number) => string = defaultFormatCount
Count beside the toolbar. It is a status region, so every change is announced.
emptyValueLabel
string = "Not set"
Text shown for a field without a value.
loading
boolean = false
loadingLabel
string = "Loading sections"
empty
React.ReactNode = "No sections to show."
Shown in place of the sections when `items` is empty.

Also accepts every prop of Omit<React.ComponentProps<"div">, "defaultValue" | "onChange" | "children"> and VariantProps<typeof accordionMultiOpenControlsVariants>.

Accessibility

Keyboard
Keyboard support for Multi-Open Accordion with Controls
KeyEffect
TabMoves to the toolbar, then to each section header and into any open panel, in document order
Arrow Left, Arrow Right in the toolbarMoves between Expand all and Collapse all
Home, End in the toolbarMoves to the first or last bulk button
Enter or Space on a bulk buttonOpens or closes every section that is not locked, and announces the new count
Enter or Space on a headerOpens or closes that section and announces the new count. A locked header does nothing
Arrow Up, Arrow Down on a headerMoves to the previous or next header, wrapping at the ends
Home, End on a headerMoves to the first or last header
Screen reader

Each header is a heading that wraps a button with aria-expanded and aria-controls. Panels are labelled regions while there are six or fewer. The bulk buttons sit in a labelled toolbar and use aria-disabled so focus is never lost. The open count beside them is a status region, so every change is announced.

  • Announces: {open} of {total} open
  • Announces: Loading sections
Reduced motion
Panels open and close instantly in every mode. The chevron rotation is not animated, and the loading skeleton does not pulse.
Checked
Not checked yet. Automated results appear here once CI has run.

Dependencies5

  • button
  • @hazine/heading
  • @hazine/use-controllable-state
  • lucide-react
  • class-variance-authority

Filled chips are registry items the CLI adds for you. Outlined chips are npm packages.

Tokens shipped0

None. The item is styled by the tokens your theme already has.

More in Data Display