Slot
Merges props and ref onto its single child. The engine behind asChild.
Installation
npx axiom add slotpnpm dlx axiom add slotyarn dlx axiom add slotbun x axiom add slotWhat it does
Slot renders its only child and merges its own props and ref onto it. Components use it to support the asChild pattern: instead of rendering their default element, they pass their behavior and props to the element you provide.
<Button asChild>
<Link href="/settings">Settings</Link>
</Button>Here the link receives the button’s props and styles, and no extra wrapper is rendered.
Features
- Merges props onto the child.
- Forwards the ref to the child.
- Expects exactly one child.