Actions
Link Button
Inline text action in gray, black, accent or error, with optional underline and icons.
react-aria-components
Preview
View allForgot password?Skip for nowTry again
Open docsDisabled
"use client";
import { ArrowRight, ExternalLink } from "lucide-react";
import { LinkButton } from "@/components/ui/link-button";
export default function Example() {
return (
<div className="flex flex-col items-center gap-4">
<div className="flex flex-wrap items-center gap-6">
<LinkButton tone="accent" trailingIcon={<ArrowRight />}>View all</LinkButton>
<LinkButton tone="black" underline>Forgot password?</LinkButton>
<LinkButton tone="gray">Skip for now</LinkButton>
<LinkButton tone="error">Try again</LinkButton>
</div>
<div className="flex flex-wrap items-center gap-6">
<LinkButton size="sm" href="https://example.com" target="_blank" trailingIcon={<ExternalLink />}>Open docs</LinkButton>
<LinkButton size="sm" isDisabled>Disabled</LinkButton>
</div>
</div>
);
}Installation
Components are copied into your project — no runtime package.
Install the following dependencies:
terminalnpm install react-aria-componentsCreate a
link-button.tsxfile and paste the following code into it.src/components/ui/link-button.tsx"use client"; import type { ReactNode } from "react"; import { Link as AriaLink, type LinkProps as AriaLinkProps } from "react-aria-components"; import { cx } from "@/utils/cx"; export interface LinkButtonProps extends Omit<AriaLinkProps, "className" | "children"> { tone?: "gray" | "black" | "accent" | "error"; size?: "sm" | "md"; underline?: boolean; leadingIcon?: ReactNode; trailingIcon?: ReactNode; className?: string; children: ReactNode; } const tones = { gray: "text-fg-secondary data-hovered:text-fg", black: "text-fg data-hovered:text-fg-secondary", accent: "text-accent-text data-hovered:text-accent-pressed", error: "text-error-text data-hovered:text-error-hover", }; /** Inline text action. Underline on hover, or always with `underline`. */ export function LinkButton({ tone = "accent", size = "md", underline, leadingIcon, trailingIcon, className, children, ...props }: LinkButtonProps) { return ( <AriaLink {...props} className={cx( "inline-flex cursor-pointer items-center gap-1 rounded-xs font-medium underline-offset-[3px] outline-none transition-colors", "data-hovered:underline data-focus-visible:shadow-focus data-disabled:cursor-default data-disabled:text-fg-disabled data-disabled:no-underline", size === "md" ? "text-base [&_svg]:size-4" : "text-sm [&_svg]:size-3.5", underline && "underline decoration-current/40", tones[tone], className, )} > {leadingIcon} {children} {trailingIcon} </AriaLink> ); }Add the theme tokens and the
cxhelper from Installation if you haven’t yet, then update the import paths to match your project setup.