Shadcn framer motion #1636
Replies: 6 comments 4 replies
-
since, Shadcn was base on RadixUI maybe this solution, solve the problem. |
Beta Was this translation helpful? Give feedback.
-
There's two ways i found out how to do it:
|
Beta Was this translation helpful? Give feedback.
-
can we config the native comp i,e the primitive's one - with out wrapping ot something like but still keeping it on server :) |
Beta Was this translation helpful? Give feedback.
-
use Component not div |
Beta Was this translation helpful? Give feedback.
-
Wrapping the Button component with motion works, but creates unexpected behaviour when the asChild prop is enabled. The animations don't trigger in a stable way, for me at least. Anyone else facing the same issue? Any fixes? |
Beta Was this translation helpful? Give feedback.
-
function Button({
className,
variant,
size,
asChild = false,
...props
}: React.ComponentProps<'button'> &
VariantProps<typeof buttonVariants> & {
asChild?: boolean
}) {
const Comp = asChild ? Slot : 'button'
const Bt = React.forwardRef((_, ref) => {
return <Comp
//@ts-ignore
ref={ref}
data-slot="button"
className={cn(buttonVariants({ variant, size, className }))}
{...props}
/>
})
const BtMotion = motion.create(Bt)
return <BtMotion whileTap={{ scale: 0.8 }}/>
} I resolved with this wrapper in the ui/components/button.tsx to avoid create a WrappedButton losting the props. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
How do i integrate the button with framer motion because is no div has anyone tried this?
Beta Was this translation helpful? Give feedback.
All reactions