Repository navigation
Closed
Description
Problem
All linkable XDS components currently render hardcoded <a> elements. This means they only support native browser navigation via href — there's no way to use framework-specific link components like Next.js <Link>, React Router <Link>, or TanStack Router <Link>.
This affects:
- XDSPageNavItem — renders
<a>whenhrefis provided - XDSTopNavItem — always renders
<a> - XDSTab — renders
<a>whenhrefis provided - XDSBreadcrumbItem — renders
<a>for non-current items - XDSLink — renders
<a>directly
Without this, users in Next.js apps get full-page reloads instead of client-side navigation, lose prefetching, and can't integrate with their router's active-route detection.
Proposal
Add a polymorphic rendering mechanism so any linkable element can render as a custom component. Two possible approaches:
Option A: as prop (per-component)
import Link from "next/link";
<XDSPageNavItem label="Dashboard" href="/dashboard" as={Link} />
<XDSTopNavItem label="Home" href="/" as={Link} />
<XDSTab value="home" label="Home" href="/" as={Link} />
<XDSBreadcrumbItem href="/projects" as={Link}>Projects</XDSBreadcrumbItem>
<XDSLink label="Docs" href="/docs" as={Link}>Docs</XDSLink>Option B: Provider-based (app-wide)
import Link from "next/link";
<XDSLinkProvider component={Link}>
<App /> {/* All linkable XDS components automatically use Next.js Link */}
</XDSLinkProvider>Option C: Both
A provider sets the default, and the as prop overrides per-instance. This is what most mature design systems do (Chakra, Mantine, etc.).
Affected Components
| Component | Current element | Has href prop |
|---|---|---|
XDSLink |
<a> |
✅ |
XDSPageNavItem |
<a> / <button> |
✅ |
XDSTopNavItem |
<a> |
✅ |
XDSTab |
<a> / <button> |
✅ |
XDSBreadcrumbItem |
<a> |
✅ |
XDSTopNavTitle |
potentially | ❌ (but could) |
Design Considerations
- The
ascomponent must receivehref,children,ref,className,style, and any ARIA props - TypeScript generics needed so props are correctly typed for the target component
- StyleX compatibility — need to verify
stylex.props()output works with framework link components - Should work with
forwardRefcomponents - Next.js
<Link>passeshrefto its child<a>, so the integration pattern may need to account for that
Prior Art
- Radix UI:
asChildwithSlotpattern - Chakra UI:
asprop - React Aria:
elementTypeprop - Mantine:
componentprop +polymorphicFactory - MUI:
componentprop +LinkComponenton theme
Metadata
Metadata
Assignees
Labels
No labels
Activity
feat(link): add polymorphic link support with XDSLinkProvider and per…
feat(link): add polymorphic link support with XDSLinkProvider and per…