BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/shadcn-htmx/link

Link

shadcn-htmx/link
FreeComponent

A native <a href> with shadcn styling — default (underlined), muted, and hover-underline variants, plus an external treatment that opens a new tab, sets rel="noopener noreferrer", and announces "(opens in new tab)".

Live preview

live · rendered by the registry
Rendered by shadcn-htmx on their own page — this is the component running, not a screenshot of it.

Install it

npx shadcn@latest add https://shadcn-htmx.productdevbook.com/r/link.json

Source

registry/ui/link.tsxshadcn-htmx.productdevbook.com/r/link.json · first 6 KB
1/** @jsxImportSource hono/jsx */
2import type { PropsWithChildren } from "hono/jsx"
3import { cn, type ClassValue } from "@/registry/lib/cn"
4
5// Link — shadcn-htmx, htmx v4 + Tailwind v4.
6//
7// shadcn/ui has no standalone "link" primitive — it styles links through the
8// Button `link` variant and the `typography` docs. We ship a dedicated,
9// text-first anchor instead. Anatomy/intent cross-checked against the Button
10// `link` variant: repos/shadcn-ui/apps/v4/registry/new-york-v4/ui/button.tsx.
11//
12// Accessibility contract — WAI-ARIA APG Link pattern:
13// repos/aria-practices/content/patterns/link/link-pattern.html
14// The APG itself says: "Authors are strongly encouraged to use a native host
15// language link element, such as an HTML <a> element with an href attribute."
16// So we render a real <a href>. That gives us, for free and without any JS:
17// - the implicit `link` role (MDN: <a> has role=link when href is present —
18// repos/mdn/files/en-us/web/html/reference/elements/a/index.md "Implicit
19// ARIA role"),
20// - Enter activates + moves focus to the target (the APG keyboard contract —
21// link-pattern.html "Keyboard Interaction": Enter executes the link),
22// - browser affordances the APG example flags as lost when you fake a link
23// with role=link on a <span>: open-in-new-tab, copy-link, drag, Shift+F10
24// context menu.
25// The APG link *examples* (link/examples/link.html) only reach for
26// role=link + tabindex=0 + onkeydown when the markup genuinely cannot be an
27// <a> (a <span> or <img>). We expose that fallback via `as` + `role="link"`,
28// but the default — and the path we document — is the native element.
29//
30// `external` sets target/rel and renders a visible "opens in new tab" icon +
31// visually-hidden text, per MDN's "External links" guidance
32// (a/index.md "External links and linking to non-HTML resources"). Modern
33// browsers treat target="_blank" as rel="noopener" implicitly; we still emit
34// rel="noopener noreferrer" so the protection is explicit and back-compatible.
35
36export type LinkVariant =
37 | "default" // underlined, primary colour — reads as a link in prose
38 | "muted" // muted-foreground, underlined — low-emphasis inline link
39 | "hover" // no underline at rest, underline on hover/focus — nav/menu link
40
41const base =
42 "inline-flex items-center gap-1 rounded-sm font-medium text-primary underline-offset-4 transition-colors outline-none " +
43// … truncated

Facts

Registry
shadcn-htmx
Type
registry:ui
Access
Free
Files written
0
Licence
MIT
First indexed
2026-08-02
Last confirmed
today

Go to the source

Docs on shadcn-htmx shadcn-htmx.productdevbook.com productdevbook/shadcn-htmx on GitHub Raw registry item This item as JSON

More from shadcn-htmx

All 83 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
Accordionaccordionshadcn-htmxComponentsFreeno deps
Active Searchactive-searchshadcn-htmxComponentsFreeno deps
Alertalertshadcn-htmxComponentsFreeno deps
Alert Dialogalert-dialogshadcn-htmxComponentsFreeno deps
Aspect Ratioaspect-ratioshadcn-htmxComponentsFreeno deps
Auto Gridauto-gridshadcn-htmxComponentsFreeno deps
Autocompleteautocompleteshadcn-htmxComponentsFreeno deps
Autosize Textareaautosize-textareashadcn-htmxComponentsFreeno deps
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex