Auto Height
optics/auto-heightFreeComponent
Auto height component for dynamic height animations.
See it running
Open the demo on optics
optics.agusmayol.com.ar/components/auto-heightInstall it
npx shadcn@latest add https://optics.agusmayol.com.ar/r/auto-height.jsonSource
1"use client";2import * as React from "react";3import { motion } from "motion/react";45import { useAutoHeight } from "@/registry/optics/hooks/use-auto-height";6import { Slot } from "@/registry/optics/helpers/primitives/animate/slot";78function AutoHeight({9 children,10 deps = [],1112 transition = {13 type: "spring",14 stiffness: 300,15 damping: 30,16 bounce: 0,17 restDelta: 0.01,18 },1920 style,21 animate,22 render,23 ...props24}) {25 const { ref, height } = useAutoHeight(deps);2627 const motionProps = {28 style: { overflow: "hidden", ...style },29 animate: { height, ...animate },30 transition,31 };3233 if (render) {34 return (35 <Slot {...motionProps} {...props}>36 {React.cloneElement(render, {37 children: (38 <>39 {render.props.children}40 <div ref={ref}>{children}</div>41 </>42 ),43 })}44 </Slot>45 );46 }4748 return (49 <motion.div {...motionProps} {...props}>50 <div ref={ref}>{children}</div>51 </motion.div>52 );53}5455export { AutoHeight };
What it pulls in
npm packages
Other registry items
Files it writes
More from optics
All 79 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | optics | Components | Free | 5 deps | |
| Alertalert | optics | Components | Free | 4 deps | |
| Alert Dialogalert-dialog | optics | Components | Free | 4 deps | |
| Aspect Ratioaspect-ratio | optics | Components | Free | 2 deps | |
| Avataravatar | optics | Components | Free | 3 deps | |
| Badgebadge | optics | Components | Free | 4 deps | |
| Breadcrumbbreadcrumb | optics | Components | Free | 4 deps | |
| Buttonbutton | optics | Components | Free | 4 deps |
