apps/docs/content/docs/en/react/migration/(components)/link.mdx
v2: Single component with icon props
v3: Compound component: Link.Icon for icons
| v2 Prop | v3 Location | Notes |
|---|---|---|
showAnchorIcon, anchorIcon | - | Use Link.Icon component with children |
isExternal | - | Use target="_blank" and rel="noopener noreferrer" |
size, color, isBlock | - | Removed (use Tailwind CSS) |
disableAnimation | - | Removed |
underline | - | Removed (use Tailwind underline, etc.) |
onPress - Event handler fired when the link is activated (via click or keyboard). Accepts a (e: PressEvent) => void callback.In v2, Link component usage:
import { Link } from "@heroui/react";
export default function App() {
return <Link href="#">Default Link</Link>;
}
In v3, Link component usage remains the same for basic cases:
import { Link } from "@heroui/react";
export default function App() {
return <Link href="#">Default Link</Link>;
}
<Tabs items={["v2", "v3"]}>
<Tab value="v2">
tsx <Link showAnchorIcon href="#"> External Link </Link> <Link showAnchorIcon anchorIcon={<CustomIcon />} href="#" > Custom Icon </Link>
</Tab>
<Tab value="v3">
tsx <Link href="#"> External Link <Link.Icon /> </Link> <Link href="#"> Custom Icon <Link.Icon> <CustomIcon /> </Link.Icon> </Link>
</Tab>
</Tabs>
<Tabs items={["v2", "v3"]}>
<Tab value="v2">
tsx <Link isExternal href="https://example.com"> External Link </Link>
</Tab>
<Tab value="v3">
tsx <Link href="https://example.com" target="_blank" rel="noopener noreferrer" > External Link <Link.Icon /> </Link>
</Tab>
</Tabs>
<Tabs items={["v2", "v3"]}>
<Tab value="v2">
tsx <Link href="#" underline="hover"> Hover to underline </Link>
</Tab>
<Tab value="v3">
tsx <Link href="#"> Hover to underline </Link> <Link href="#" className="underline underline-offset-2"> Underline with offset </Link>
</Tab>
</Tabs>
<Tabs items={["v2", "v3"]}> <Tab value="v2"> ```tsx import NextLink from "next/link"; import { Link } from "@heroui/react";
<Link as={NextLink} href="/about">
About
</Link>
```
The v3 Link follows this structure:
Link (Root)
├── Link content (text)
└── Link.Icon (optional)
showAnchorIcon and anchorIcon props replaced with Link.Icon componentisExternal prop removed - handle manually with target and reltext-sm, text-base, text-lg)text-primary, text-danger, etc.)block, hover:bg-surface)underline, no-underline, underline-offset-1, etc.) to customize it.as or asChild; use your router's Link with Tailwind classes (e.g. link, link__icon) for consistent stylingdisableAnimation prop removedonPress Handler: New onPress prop available for handling link activation events (click or keyboard)