Skip to content
  1. Keyline UI
  2. Accordion
Keyline UIComponents
  • Get started
    • Installation
    • Theming
    • Modes
    • Configuration
    • Composition
  • Actions
    • Button
    • Button group
    • Split button
    • Toggle
    • Toggle group
    • Toolbar
    • Menu
    • Menubar
    • Context menu
  • Inputs
    • Field and form
    • Checkbox
    • Checkbox group
    • Radio group
    • Switch
    • Slider
    • Segmented
    • Select
    • Native select
    • Combobox
    • Multiselect
    • Number field
    • OTP field
    • Time field
    • Date picker and calendar
    • Date range
  • Data
    • Table
    • Chart
    • Stat and meter
    • Status and badge
    • Progress
    • Skeleton
    • Empty
    • Avatar
    • Kbd
    • Marker
  • Navigation
    • Tabs
    • Breadcrumb
    • Pagination
    • Nav
    • Navigation menu
    • Command menu
  • Overlays
    • Dialog
    • Alert dialog
    • Drawer
    • Sheet
    • Popover
    • Hover card
    • Tooltip
    • Toast
    • Notice
  • Layout
    • App shell
    • Sidebar
    • Panel
    • Resizable
    • Scroll area
    • Accordion
    • Collapsible
    • Carousel
    • Inspector
    • Item
    • Direction
  • Conversation
    • Message
    • Bubble
    • Message scroller
    • Attachment
    • Questionnaire
  • Blocks
    • Shipments

Accordion

Stacked sections in one frame. A panel unfolds from its header's bottom keyline while the header stays still, and the caret turns. Headers are headings, Tab moves between them, and find-in-page opens a closed panel that holds the match.

Loading the live example…

"use client"

import { Accordion, AccordionItem, AccordionPanel, AccordionTrigger } from "@/components/keyline/ui/accordion"

const POLICIES = [
  {
    value: "returns",
    title: "Returns",
    meta: "30 days",
    body: "Unopened cases come back within 30 days for a full refund. Darryl collects them on the next delivery run, so nobody needs to drive to the warehouse.",
  },
  {
    value: "delivery",
    title: "Delivery",
    meta: "Free over 20 cases",
    body: "Orders of 20 cases or more are delivered free anywhere in Lackawanna County. Smaller orders pay a flat $25, or the client can pick them up at the loading dock.",
  },
  {
    value: "discounts",
    title: "Volume discounts",
    meta: "Up to 12%",
    body: "Reps can take up to 8% off an order of 100 cases without asking. Anything past that, up to 12%, needs Michael's signature, which he'll give if you ask nicely.",
  },
]

export function BranchPolicies() {
  return (
    <Accordion multiple defaultValue={["returns"]}>
      {POLICIES.map((p) => (
        <AccordionItem key={p.value} value={p.value}>
          <AccordionTrigger meta={p.meta}>{p.title}</AccordionTrigger>
          <AccordionPanel>
            <p className="m-0 max-w-[60ch] text-[14px] leading-6">{p.body}</p>
          </AccordionPanel>
        </AccordionItem>
      ))}
    </Accordion>
  )
}

Installation

npx shadcn@latest add @keyline-ui/accordion

Run it where your components.json is. The first time, map the @keyline-ui registry: one command, in Installation.

Usage

import { Accordion, AccordionItem, AccordionPanel, AccordionTrigger } from "@/components/keyline/ui/accordion"
<Accordion multiple defaultValue={["returns"]}>
  <AccordionItem value="returns">
    <AccordionTrigger meta="30 days">Returns</AccordionTrigger>
    <AccordionPanel>…</AccordionPanel>
  </AccordionItem>
</Accordion>

Props

PropTypeDefaultDescription
multiplebooleanDefault falseOn Accordion: let several panels stay open.
value · defaultValuestring[]Default —The open items, controlled with onValueChange.
layout"control" | "cell"Default "control"cell puts the rows straight into an enclosing frame.
meta · descriptionReactNodeDefault —On AccordionTrigger: text before the caret, and a line under the title.
level2 – 6Default 3On AccordionTrigger: the header's heading level.
flushbooleanDefault falseOn AccordionPanel: no inset, for content with its own cells.

Built on Base UI Accordion. For one disclosure on its own, use Collapsible.

Sheet 62 of 73PreviousScroll areaNextCollapsible
On this page