$npx @dinachi/cli@latest add link
childrenvariantdefault
muted
plain
unstyled
externaldocs-link.tsx
import { Link } from "@/components/ui/link"
export function DocsLink() {
return <Link href="#">DinachiUI Documentation</Link>
}Usage
import { Link } from "@/components/ui/link"
export function DocsLink() {
return <Link href="/docs">Read the docs</Link>
}Examples
A link in the default style.
import { Link } from '@/components/ui/link';
export function Example() {
return <Link href="#">DinachiUI Documentation</Link>;
}Default, muted, plain and unstyled.
import { Link } from '@/components/ui/link';
export function Example() {
return (
<div className="flex flex-col gap-4">
<Link href="#" variant="default">Default link with underline</Link>
<Link href="#" variant="muted">Muted link for secondary actions</Link>
<Link href="#" variant="plain">Plain link without underline</Link>
<Link href="#" variant="unstyled">Unstyled link for custom styling</Link>
</div>
);
}Opens in a new tab and shows an icon.
import { Link } from '@/components/ui/link';
export function Example() {
return (
<div className="flex flex-col gap-4">
<Link href="https://github.com" external>GitHub</Link>
<Link href="https://react.dev" external variant="muted">React Documentation</Link>
</div>
);
}Use the render prop to compose with framework routers like Next.js Link or React Router Link.
Swaps the anchor for another element, such as a router link.
import { Link } from '@/components/ui/link';
// import NextLink from 'next/link';
export function Example() {
// <Link render={<NextLink href="/about" />}>About</Link>
return (
<Link render={<button type="button" />}>
Renders as a button
</Link>
);
}The function form receives merged props (className, ref, etc.) and gives you full control over how they are applied.
Spreads the props onto your own element.
import { Link } from '@/components/ui/link';
// import NextLink from 'next/link';
export function Example() {
// <Link render={(props) => <NextLink {...props} href="/about" />}>About</Link>
return (
<Link render={(props) => <button type="button" {...props} />} variant="muted">
Render function
</Link>
);
}Notes
Router links
render takes an element or a function, as in Base UI. Either renders one element and one tab stop.
import NextLink from "next/link"
<Link render={<NextLink href="/about" />}>About</Link>
<Link render={(props) => <NextLink {...props} href="/about" />}>About</Link>React Router: render={<RouterLink to="/about" />}.
Styling other elements
import { linkVariants } from "@/components/ui/link"
<a className={linkVariants({ variant: "muted" })}>Styled anchor</a>Agents
Link does not register with the agent bridge. The bridge lists any a[href] as link, with the href as value, taking press. An a without href is not listed.
await agent.act({ steps: [{ ref: "Pricing", action: "press" }] })API
href
The destination. The agent reads it as value.agent
stringvariant"default" | "muted" | "plain" | "unstyled" = "default"
The visual style. unstyled adds only the focus ring.externalboolean = false
Opens in a new tab; adds an icon and screen reader note.targetstring = "_blank" when external
Overrides the external default.relstring = "noopener noreferrer" when external
Overrides the external default.renderReactElement | (props, state) => ReactElement
Swap the element, such as a router link, keep the styles.variant"default" | "muted" | "plain" | "unstyled" = "default"
The same styles Link takes.Accessibility
- A native anchor, announced as a link and reached by Tab.
- External links add hidden "(opens in a new tab)" text; the icon is aria-hidden.
- The focus ring shows on keyboard focus only.
Keyboard
EnterFollows the link
EnterFollows the link