skills/radix-to-base-ui-migration/01-asChild-to-render.md
The asChild pattern from Radix UI has been replaced with the render prop pattern from Base UI.
When a component uses asChild to render as a different element, replace it with a render prop. The child element becomes the render prop value, and the child's children move up to become the parent's direct children.
Any component that previously accepted asChild:
ButtonDialogTrigger, AlertDialogTriggerPopoverTriggerSheetTrigger, DrawerTriggerTooltipTriggerDropdownMenuTriggerContextMenuTriggerCollapsibleTriggerNavigationMenuLinkSlot under the hood<Button asChild>
<Link to="./new">
<PlusIcon className="mr-2 h-4 w-4" />
New Item
</Link>
</Button>
<Button render={<Link to="./new" />}>
<PlusIcon className="mr-2 h-4 w-4" />
New Item
</Button>
<DialogTrigger asChild>
<Button variant="outline">Open Dialog</Button>
</DialogTrigger>
<DialogTrigger render={<Button variant="outline" />}>
Open Dialog
</DialogTrigger>
<TooltipTrigger asChild>
<label className="text-sm cursor-default">Permission</label>
</TooltipTrigger>
<TooltipTrigger render={<label className="text-sm cursor-default" />}>
Permission
</TooltipTrigger>
<PopoverTrigger asChild>
<Button variant="outline" size="sm">
<FilterIcon className="mr-2 h-4 w-4" />
Filters
</Button>
</PopoverTrigger>
<PopoverTrigger render={<Button variant="outline" size="sm" />}>
<FilterIcon className="mr-2 h-4 w-4" />
Filters
</PopoverTrigger>
asChild prop (the "parent")render={<ChildTag ...childProps />}asChild prop from the parentrender={<ChildTag />}render prop JSX — they go as children of the parent element