dentil

Link

Link is a text link whose chevron turns into an arrow on hover. With external it opens a new tab and shows an external link icon instead. Long labels truncate, like the invoice ID capped with max-w-48.

@dentil/link
On this page

Installation

pnpm dlx shadcn@latest add @dentil/link
npx shadcn@latest add @dentil/link
yarn dlx shadcn@latest add @dentil/link
bunx --bun shadcn@latest add @dentil/link

Files land in components/dentil/link/. It uses no shadcn components, only lucide-react icons and your theme's primary colour.

Usage

The link inherits the surrounding font size. With no linkComponent it renders a plain <a>, which reloads the page on click.

import { Link } from '@/components/dentil/link/link';

<Link href="/customers/cus_123">View customer</Link>
<Link href="/invoices" arrow={false}>All invoices</Link>
<Link href="https://stripe.com/docs" external>Stripe docs</Link>

Next.js

Pass next/link directly, or wrap it to set its own props.

import NextLink from 'next/link';

import { Link, type LinkComponentProps } from '@/components/dentil/link/link';

<Link href="/customers/cus_123" linkComponent={NextLink}>
  View customer
</Link>

// To set next/link props such as prefetch, wrap it once:
const NoPrefetchLink = (props: LinkComponentProps) => <NextLink prefetch={false} {...props} />;

React Router

Adapt its Link once, since it takes to instead of href.

import { Link as RouterLink } from 'react-router';

import { Link, type LinkComponentProps } from '@/components/dentil/link/link';

// React Router's Link takes `to`, so adapt it once:
const AppLink = ({ href, ...props }: LinkComponentProps) => <RouterLink to={href} {...props} />;

<Link href="/customers/cus_123" linkComponent={AppLink}>
  View customer
</Link>

API reference

Link

PropTypeDefaultDescription
hrefstring—Where the link goes. Passed to linkComponent unchanged.
arrowbooleantrueShows a chevron after the label that turns into an arrow on hover and keyboard focus. Ignored when external is set.
externalbooleanfalseSets target="_blank" and rel="noopener noreferrer", and shows an external link icon with screen reader text saying it opens a new tab. Pass target or rel to override them.
linkComponentElementType<LinkComponentProps>'a'Renders the anchor. Pass next/link directly, or adapt a router link that takes to.
labelClassNamestring—Merged onto the label. The label truncates with an ellipsis when the link is narrower than it.
classNamestring—Merged onto the anchor.
…propsOmit<ComponentProps<'a'>, 'href'>—Other anchor props, such as onClick, title and aria-* attributes, go to linkComponent.