asChild

A prop that tells a component to render its single child element instead of its own, merging its classes, props and behaviour onto that child.

In more detail

<Button asChild><a href="/home">Home</a></Button> renders one <a> that looks and behaves like the design system button, with no extra wrapper element. It replaces the older as prop and keeps TypeScript types simple because the child is an ordinary element. Radix UI introduced it using a Slot component.

Related terms

Taught in

References