In Base UI, a link that looks like a button is still a link
Why shadcn's Base UI Button should never render an <a>, what Base UI and shadcn say about it, and the line in Base UI's source that settles it.
Audrey KlammerBase UIshadcnAccessibility
If you came to shadcn/ui from the Radix version, you know this move: wrap a
link in Button with asChild, and the link looks like a button. The Base UI
version of shadcn has a prop that seems to do the same job, render. It
doesn't. Here is why, with the sources.
The pattern that looks right
<Button render={<a href="/pricing" />} nativeButton={false}>
See pricing
</Button>
It renders an <a> with an href. It looks like a button. It even
navigates. But to a screen reader it is no longer a link.
What Base UI says
Base UI's Button page has a section on exactly this,
Rendering links as buttons.
It says Button enforces button semantics. nativeButton={false} is for an
element that isn't a <button> but should still act as one, like a <div>.
A link has semantics of its own, so it shouldn't go through render. Their
advice: style the <a> directly.
The page's usage guidelines put it more plainly: Button should not be used for links.
What shadcn says
shadcn's Base UI Button page has an
As Link section
with a bold warning against <Button render={<a />} nativeButton={false} />
for links. The reason given: Base UI's Button always applies role="button",
which overrides the link role on the <a>. Their fix is the buttonVariants
helper on a plain <a>
(source of that page).
Compare the
Radix version of the same page,
which still shows asChild wrapping a Next.js Link. That's why the habit
carries over, and why it breaks when you switch.
The line in the source
You don't have to take either page's word for it. In Base UI's useButton,
the hook behind Button, a non-native button gets its role here
(useButton.ts, line 226, v1.9.0):
isNativeButton ? { type: "button" } : { role: "button" }
With nativeButton={false}, every element Button renders gets
role="button", an <a href> included. The role wins over the element, so
assistive technology announces a button. People who browse by a list of
links won't find it there, and "button" tells them it does something on this
page rather than going somewhere.
What to write instead
A link, styled with the button's classes:
import { buttonVariants } from "@/components/ui/button"
;<a href="/pricing" className={buttonVariants({ variant: "outline" })}>
See pricing
</a>
With Next.js, the same with Link:
import Link from "next/link"
;<Link href="/pricing" className={buttonVariants({ variant: "outline" })}>
See pricing
</Link>
It looks identical, and it stays a link: announced as one, listed with the others, opens in a new tab on a middle click.
The short rule
- It goes somewhere: a link (
<a>orLink) withbuttonVariants. - It does something here:
Button. nativeButton={false}is for a button drawn on a non-button element, never for a link.
Every link 01orbital writes follows that rule, so the links you install stay
links. One stock part is the exception: shadcn's own Pagination draws each
page link through Button with nativeButton={false}
(pagination.tsx, lines 44 to 66),
and the kit ships stock parts as shadcn wrote them.