Link

A link lets users navigate to other pages or resources within a website or app, helping them find related content quickly and easily.

Example

tone
Usage

Features

Links can be created in HTML with the <a> element with an href attribute. However, if the link does not have an href, and is handled client side with JavaScript instead, it will not be exposed to assistive technology properly. Link helps achieve accessible links with either native HTML elements or custom element types.

  • Flexible – Support for HTML navigation links, JavaScript handled links, and client side routing. Disabled links are also supported.
  • Accessible – Implemented as a custom ARIA link when handled via JavaScript, and otherwise as a native HTML link.
  • Styleable – Hover, press, and keyboard focus states are provided for easy styling. These states only apply when interacting with an appropriate input device, unlike CSS pseudo classes.

Installation

Install following dependencies:

npm install react-aria-components tw-animate-css tailwindcss-react-aria-components class-variance-authority lucide-react clsx tailwind-merge motion

Add cn helper using clsx and twMerge for conditional class merging in Tailwind components.

lib/utils.ts

Copy and paste the following code into your project.

components/ui/core/link.tsx
npx @libravelui@latest add link

Anatomy

import { Link } from "@/components/ui/core/link";
<Link href="#" tone="default">Default Link</Link>
<Link href="#" tone="primary">Primary Link</Link>
<Link href="#" tone="secondary">Secondary Link</Link>
<Link href="#" tone="underline">Underline Link</Link>

Props

Loading types…