BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/@nswds/ui/link

Link

nswds-ui/link
FreeComponent

A link primitive with a provider for app router link components.

Install it

npx shadcn@latest add https://raw.githubusercontent.com/digitalnsw/nswds-ui/main/apps/registry/public/r/link.json

Source

src/components/link.tsxraw.githubusercontent.com/digitalnsw/nswds-ui/main/apps/registry/public/r/link.json · first 6 KB
1'use client'
2
3import { cva, type VariantProps } from 'class-variance-authority'
4import React, { createContext, useContext } from 'react'
5
6import { cn } from '@/lib/utils'
7
8// Shared visual base for all *styled* variants. Pulled out so the `unstyled`
9// variant can omit it entirely (otherwise it wouldn't actually be unstyled).
10const styledBase = [
11 // Typography + transition
12 'font-medium underline decoration-current underline-offset-4 motion-safe:transition-colors',
13 // Text colour derives from --link-color; --link-halo and --link-halo-active
14 // derive from --link-color via color-mix so each variant only sets the one
15 // token and the hover/active halos follow automatically.
16 'text-(--link-color)',
17 '[--link-halo:color-mix(in_oklch,var(--link-color)_10%,transparent)]',
18 '[--link-halo-active:color-mix(in_oklch,var(--link-color)_18%,transparent)]',
19 // Hover / active halos use box-shadow + background-color rather than
20 // padding, so inline links sit flush against surrounding text. The
21 // shadows extend the halo 2px above and 4px below the line box, matching
22 // the GOV.UK Design System focus pattern.
23 'hover:bg-(--link-halo) hover:decoration-2',
24 'hover:shadow-[0_-2px_0_var(--link-halo),0_4px_0_var(--link-halo)]',
25 // Wrapped lines each get their own halo
26 '[box-decoration-break:clone] [-webkit-box-decoration-break:clone]',
27 'focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--link-color)',
28 // Default sizing for icon children — without this, an unsized SVG inside
29 // a Link collapses to 0×0 in flex layouts. `vertical-align: -0.15em`
30 // aligns the icon's box to the text's x-height for inline-flow usage;
31 // flex contexts ignore vertical-align and should set `items-baseline` (or
32 // similar) on the Link itself. Consumers can override per-icon by passing
33 // a `size-*` or `align-*` class on the icon itself.
34 '*:data-[slot=icon]:inline-block *:data-[slot=icon]:size-[1em] *:data-[slot=icon]:shrink-0 *:data-[slot=icon]:align-[-0.15em]',
35]
36
37const linkVariants = cva('', {
38 variants: {
39 variant: {
40 primary: [
41 ...styledBase,
42 // Link
43 '[--link-color:var(--color-primary-800)] dark:[--link-color:var(--color-primary-200)]',
44 // Visited — set the text colour directly. `:visited` is restricted by
45 // browsers to a small set of paint-only properties (color, *-color,
46 // fill, stroke) and ignores custom properties, so we can't shift
47// … truncated

What it pulls in

npm packages

  • class-variance-authority
  • clsx
  • tailwind-merge

Other registry items

  • https://ui.digital.nsw.gov.au/registry/r/theme.json

Files it writes

  • src/components/link.tsx
  • src/lib/utils.ts

Facts

Registry
@nswds/ui
Type
registry:ui
Access
Free
Files written
2
Licence
MIT
In the index
at or before 2026-08-20
Last confirmed
today

Go to the source

ui.digital.nsw.gov.au digitalnsw/nswds-ui on GitHub Raw registry item This item as JSON

More from @nswds/ui

All 46 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
Aspect Ratioaspect-ratio@nswds/uiComponentsFree2 deps · 2 files
Badgebadge@nswds/uiComponentsFree4 deps · 2 files
Buttonbutton@nswds/uiComponentsFree4 deps · 2 files
Cardcard@nswds/uiComponentsFree2 deps · 2 files
Collapsiblecollapsible@nswds/uiComponentsFree1 dep
Drawerdrawer@nswds/uiComponentsFree3 deps · 2 files
Expandable Searchexpandable-search@nswds/uiComponentsFree3 deps · 2 files
Fieldfield@nswds/uiComponentsFree4 deps · 2 files

Also from Kynth Studios

Built for the same person as BlockDex

SkillWorks

Claude Code skills and plugins, scored

skillworks.kynth.studio

RuleStack

AGENTS.md gallery and agent-config comparison

rulestack.kynth.studio

KitGrade

SaaS starter kits, scored on what can be checked

kitgrade.kynth.studio

The studio list

One product, taken apart, once a month

Kynth Studios pulls one shipped product open every month — what it does, what it cost to build, what the pipeline behind it looks like, and what the numbers did. One email a month, nothing in between.

Double opt-in — we send one confirmation link and nothing else until you click it.

BlockDex

Built by

Kynth Studios

the studio behind SkillWorks, RuleStack and KitGrade

part of Toolproof, the measurement layer for AI agent tooling

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

© 2026 BlockDex. A Kynth Studios product. Changelog

BlockDex

The studio list

One product, taken apart, once a month

Kynth Studios pulls one shipped product open every month — what it does, what it cost to build, what the pipeline behind it looks like, and what the numbers did. One email a month, nothing in between.

Double opt-in — we send one confirmation link and nothing else until you click it.

BlockDex

Built by

Kynth Studios

the studio behind SkillWorks, RuleStack and KitGrade

part of Toolproof, the measurement layer for AI agent tooling

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

© 2026 BlockDex. A Kynth Studios product. Changelog

BlockDex

The studio list

One product, taken apart, once a month

Kynth Studios pulls one shipped product open every month — what it does, what it cost to build, what the pipeline behind it looks like, and what the numbers did. One email a month, nothing in between.

Double opt-in — we send one confirmation link and nothing else until you click it.

BlockDex

Built by

Kynth Studios

the studio behind SkillWorks, RuleStack and KitGrade

part of Toolproof, the measurement layer for AI agent tooling

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

© 2026 BlockDex. A Kynth Studios product. Changelog

BlockDex