recursiveCloneChildren
Recursively clones children, adding additional props to components with matched display names.
Installation
Create a utils/recursive-clone-children.tsx
file and paste the following code into it.
/utils/recursive-clone-children.tsx
Examples
Without asChild
If the component doesn't use Slot
from @radix-ui/react-slot, you don't need to worry about the last parameter of the recursiveCloneChildren
function.
Here is an example without asChild
:
/demo-recursive-clone-children.tsx
Here is how to use Box component:
/demo-recursive-clone-children.tsx
With asChild
Let's consider the example above with asChild
.
Here are the lines to add:
/demo-recursive-clone-children.tsx
© 2024 AlignUI Design System. All rights reserved.