npmshadcn · Web componentshadcn · React + TailwindManualnpminstall@purpurabog/uinpxshadcn@4add@kanok-ui/linknpxshadcn@4add@kanok-ui/tw-link# Web component# 1. Install the dependenciesnpminstalllit@^3.3.0# 2. Copy each file's "content" from# https://cdn.jsdelivr.net/npm/@purpurabog/ui@2.3.0/registry/link.json# to its target:# components/ui/primitives/link/link.ts# 3. Do the same for the items it needs (registry/<name>.json):# shared-element, shared-navigate, shared-slots, tokens# React + Tailwind# 1. Install the dependenciesnpminstallclass-variance-authority@0.7.1# 2. Copy each file's "content" from# https://cdn.jsdelivr.net/npm/@purpurabog/ui@2.3.0/registry/tw-link.json# to its target:# components/ui/react-tw/link.tsx# 3. Do the same for the items it needs (registry/<name>.json):# tw-theme, tw-utils
npm gives you every component from the package. shadcn copies the source into your app instead: a copy pinned to this version that you can change. The shadcn commands need the @kanok-ui registry in your components.json once, see Installation.
inline underlines the link at rest, so it stands out in running text where colour alone isn't enough. An inline link shows no icon.
Signed copies are kept for 10 years under the retention policy. Ask the legal team before you destroy one.
HTMLReactReact + Tailwind<p>Signed copies are kept for 10 years under the <ui-linkhref="#link-retention"inline>retention policy</ui-link>. Ask the legal team before you destroy one.</p><p>Signed copies are kept for 10 years under the <UiLinkhref="/policies/retention"inline>retention policy</UiLink>. Ask the legal team before you destroy one.</p><p>Signed copies are kept for 10 years under the <Linkhref="/policies/retention"inline>retention policy</Link>. Ask the legal team before you destroy one.</p>
With an icon
Put a 16px icon in the icon slot (the icon prop in React + Tailwind): it sits 8px after the text, in the link's colour, and grows to 20px with size="lg". Use it for standalone links, such as "View all" at the end of a list.
target="_blank" opens the page in a new tab, and the link adds rel="noopener noreferrer" unless you set rel. Say so in the text or with Carbon's Launch icon, so the new tab doesn't surprise anyone.
download makes the link save its target instead of opening it; its value is the file name. Name the type and size in the text. (The docs site has no such file, so this demo builds one in the browser.)
Download the contract checklist (TXT, 1 KB)
HTMLReactReact + Tailwind<ui-linkid="link-download"href="/files/contract-checklist.txt"download="contract-checklist.txt">Download the contract checklist (TXT, 1 KB)</ui-link>
<scripttype="module">
const link = document.getElementById('link-download');
const text ='Contract checklist\n- Both parties named\n- Amount and due dates\n- Signatures and witnesses\n';
link.href = URL.createObjectURL(newBlob([text], { type:'text/plain' }));
</script><UiLinkhref="/files/contract-checklist.txt"download="contract-checklist.txt">
Download the contract checklist (TXT, 1 KB)
</UiLink><Linkhref="/files/contract-checklist.txt"download="contract-checklist.txt">
Download the contract checklist (TXT, 1 KB)
</Link>
Visited links
visited turns on Carbon's visited colour (purple) for links the browser has visited. Use it in lists the user works through, such as search results. Click the link, then look at it again.
disabled renders grey text with role="link" and aria-disabled="true": it isn't a link any more and takes no focus. Prefer leaving the link out, or explain next to it why it is unavailable.
Download the signed copy
HTMLReactReact + Tailwind<ui-linkhref="#link-signed"disabled>Download the signed copy</ui-link><UiLinkhref="/contracts/ct-2026-0142/signed.pdf"disabled>Download the signed copy</UiLink><Linkhref="/contracts/ct-2026-0142/signed.pdf"disabled>Download the signed copy</Link>
Route in a single-page app
A plain click (main button, no modifier key, same tab, same site, not a download) first fires a cancelable ui-navigate with detail.href. Call preventDefault() and hand the path to your router; the browser then doesn't load the page. Ctrl-, ⌘- and middle-clicks stay normal links. The React + Tailwind Link is a plain <a>: route in its onClick, or wrap your router's link.
Open CT-2026-0142
Router got:
HTMLReactReact + Tailwind<ui-linkid="link-route"href="/contracts/ct-2026-0142">Open CT-2026-0142</ui-link>
<p>Router got: <outputid="link-route-out"></output></p>
<scripttype="module">
const link = document.getElementById('link-route');
const out = document.getElementById('link-route-out');
link.addEventListener('ui-navigate', (event) => {
event.preventDefault();
out.value = event.detail.href;
});
</script>const navigate =useNavigate(); // your router
<UiLinkhref="/contracts/ct-2026-0142"onUiNavigate={(e) => { e.preventDefault(); navigate(e.detail.href); }}>
Open CT-2026-0142
</UiLink>const navigate =useNavigate(); // your router
<Linkhref="/contracts/ct-2026-0142"onClick={(e) => {
if (e.button !==0|| e.metaKey || e.ctrlKey || e.shiftKey) return;
e.preventDefault();
navigate('/contracts/ct-2026-0142');
}}
>
Open CT-2026-0142
</Link>
Accessibility
The link is a real <a href>: Enter follows it, and the browser's menu (open in a new tab, copy the address) works.
Write text that makes sense on its own ("Download the contract checklist", not "Click here"): screen reader users often move from link to link.
Icons in the icon slot are decoration; give them aria-hidden="true" and keep the meaning in the text.
A disabled link is announced as a dimmed link but takes no focus, so keyboard users never reach it. Say why it is unavailable in nearby text.
inline underlines links inside sentences, so they don't rely on colour alone.
API
Generated from the package. In React, pass a property as a prop of the same name; events are props too (the React column).
<ui-link> · React UiLink
Attributes
Attribute
Property
Type
Default
Description
href
href
string
''
target
target
string
''
rel
rel
string
''
download
download
string
''
size
size
LinkSize
'md'
inline
inline
boolean
false
Underlined at rest, for links inside a sentence.
visited
visited
boolean
false
Opt into Carbon's visited colour (browser :visited).
disabled
disabled
boolean
false
Renders as inert text with aria-disabled.
Events
Event
React
Description
ui-navigate
none (use a ref)
detail: { href } (cancelable) on a plain click of the link; cancel it to route client-side (README: SPA router)
Slots
Slot
Description
(default)
Link text
icon
A 16px (lg: 20px) icon after the text (Carbon renderIcon; not shown when inline)