driftkit
ComponentsAccordion

Accordion

Motion-first accordion with height animations, staggered content reveals, and keyboard navigation. Supports single or multiple open panels.

Layout

Installation

Copy and paste

Copy the component source code and paste it into your project.

import { Accordion } from "driftkit";

Props

NameTypeRequiredDescription
itemsAccordionItem[]YesArray of accordion items. Each has value (key), trigger (header content), content (panel content), and optional disabled flag.
type"single" | "multiple"NoSingle allows only one panel open at a time. Multiple allows any combination.
valuestring[]NoControlled open values. Array of item values that are currently open.
defaultValuestring[]NoDefault open values for uncontrolled usage.
onValueChange(value: string[]) => voidNoCallback when open state changes. Receives array of open item values.
🎮

Playground

Tune spring physics for this component

Live Preview

Accordion Component

Spring Physics

300
30
1

Generated Code

const springConfig = {
  "type": "spring",
  "stiffness": 300,
  "damping": 30,
  "mass": 1
};

// Basic hover animation
<motion.div
  whileHover={{ scale: 1.05 }}
  whileTap={{ scale: 0.95 }}
  transition={springConfig}
>
  <Accordion />
</motion.div>

// Advanced with custom animations
<motion.div
  animate={{ 
    scale: [1, 1.02, 1],
    y: [0, -4, 0]
  }}
  transition={{
    ...springConfig,
    repeat: Infinity,
    repeatDelay: 2
  }}
>
  <Accordion />
</motion.div>
Stiffness: Controls animation speed. Higher values create snappier animations.
Damping: Controls resistance to motion. Lower values create more bounce and overshoot.
Mass: Controls the perceived weight. Higher values make animations slower with more momentum.

Source Code

View the source code on GitHub to see the full implementation.

View on GitHub