Dropdown
Motion-first dropdown menu with staggered item animations, keyboard navigation, click-outside dismissal, and portal rendering. Features spring physics and WAI-ARIA compliance.
Navigation
Installation
Copy and paste
Copy the component source code and paste it into your project.
import { Dropdown } from "driftkit";Props
| Name | Type | Required | Description |
|---|---|---|---|
trigger | ReactNode | Yes | The trigger element that opens the dropdown when clicked. Can be a button, text, or any clickable element. |
items | DropdownItem[] | Yes | Array of dropdown items. Each has label, onClick callback, optional icon, disabled flag, and separator flag. |
align | "left" | "right" | No | Menu alignment relative to trigger. Left aligns left edges, right aligns right edges. |
🎮
Playground
Tune spring physics for this component
Live Preview
Select option...▼
Design
Engineering
Marketing
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}
>
<Dropdown />
</motion.div>
// Advanced with custom animations
<motion.div
animate={{
scale: [1, 1.02, 1],
y: [0, -4, 0]
}}
transition={{
...springConfig,
repeat: Infinity,
repeatDelay: 2
}}
>
<Dropdown />
</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