Accordion

A collapsible content panel that toggles between expanded and collapsed states. Useful for organizing long-form content into manageable sections.

import { Accordion } from "@tenstorrent/vesper/accordion";

export default function AccordionDemo() {
  return (
    <Accordion title="Click to expand">
      This is the accordion content. It can contain any text or elements.
    </Accordion>
  );
}

Options

PropTypeDescriptionDefault
titlestringThe title text displayed in the accordion trigger.—
defaultOpenbooleanWhether the accordion is open by default (uncontrolled mode).false
openbooleanControls the open state of the accordion (controlled mode).—
onOpenChange(open: boolean) => voidCallback fired when the open state changes.—
childrenReactNodeThe content displayed when the accordion is expanded.—

You may also pass additional props to the underlying div element. For example, you may wish to give the <Accordion> instance a custom max-width, aria-label, etc.

Examples

Basic usage

Render an Accordion by giving it a title and children, leaving it to keep track of its own open/closed state:

import { Accordion } from "@tenstorrent/vesper/accordion";

export default function BasicAccordion() {
  return <Accordion title="Section Title">Content goes here.</Accordion>;
}

Default open state

You can render an Accordion in a default opened state by passing defaultOpen:

This accordion starts expanded.
import { Accordion } from "@tenstorrent/vesper/accordion";

export default function DefaultOpenAccordion() {
  return (
    <Accordion title="Already Open" defaultOpen>
      This accordion starts expanded.
    </Accordion>
  );
}

Controlled usage

If you need to control the open/closed state of the Accordion, you can do so via the open and onOpenChange props:

import { useState } from "react";

import { Accordion } from "@tenstorrent/vesper/accordion";

export default function ControlledAccordion() {
  const [open, setOpen] = useState(false);

  return (
    <Accordion title="Controlled" open={open} onOpenChange={setOpen}>
      Controlled accordion content.
    </Accordion>
  );
}