Collapsible
scrollxui/collapsibleFreeComponent
An interactive component which expands/collapses a panel with a smooth motion.
Live preview
live · rendered by the registry
Rendered by scrollxui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://scrollxui.dev/registry/collapsible.jsonSource
1'use client';2import * as React from 'react';3import * as CollapsiblePrimitive from '@radix-ui/react-collapsible';4import { motion } from 'motion/react';56function Collapsible({7 ...props8}: React.ComponentProps<typeof CollapsiblePrimitive.Root>) {9 return <CollapsiblePrimitive.Root data-slot='collapsible' {...props} />;10}1112function CollapsibleTrigger({13 ...props14}: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleTrigger>) {15 return (16 <CollapsiblePrimitive.CollapsibleTrigger17 data-slot='collapsible-trigger'18 asChild19 {...props}20 >21 <motion.div22 whileHover={{ scale: 1.01 }}23 whileTap={{ scale: 0.99 }}24 transition={{ duration: 0.2 }}25 >26 {props.children}27 </motion.div>28 </CollapsiblePrimitive.CollapsibleTrigger>29 );30}3132function CollapsibleContent({33 ...props34}: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleContent>) {35 return (36 <CollapsiblePrimitive.CollapsibleContent37 data-slot='collapsible-content'38 asChild39 {...props}40 >41 <motion.div42 initial={{ height: 0, opacity: 0 }}43 animate={{ height: 'auto', opacity: 1 }}44 exit={{ height: 0, opacity: 0 }}45 transition={{46 duration: 0.3,47 ease: 'easeInOut',48 }}49 style={{ overflow: 'hidden' }}50 >51 {props.children}52 </motion.div>53 </CollapsiblePrimitive.CollapsibleContent>54 );55}5657export { Collapsible, CollapsibleTrigger, CollapsibleContent };
What it pulls in
npm packages
Files it writes
More from scrollxui
All 180 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | scrollxui | Components | Free | 4 deps | |
| Alert Dialogalert-dialog | scrollxui | Components | Free | 7 deps | |
| Animated Buttonanimated-button | scrollxui | Components | Free | 4 deps | |
| Animated Tabsanimated-tabs | scrollxui | Components | Free | 1 dep | |
| Animated Testimonialsanimated-testimonials | scrollxui | Components | Free | 2 deps | |
| Animated TextGenerateanimated-textgenerate | scrollxui | Components | Free | 3 deps | |
| Announcementannouncement | scrollxui | Components | Free | 5 deps | |
| Aspect Ratioaspect-ratio | scrollxui | Components | Free | 1 dep |
