Link

A styled anchor that can render a router link.

Source
$npx @dinachi/cli@latest add link
children
variant
external

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>;
}

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
agent
string
The destination. The agent reads it as value.
variant"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.

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.