Link
Links use the accent color, which is the theme color in
oklch unless you set --secondary yourself.
| Class | Does what |
|---|---|
link | Accent-colored text with a pointer cursor |
Basic
<div class="prose">
<p>Read the <a href="#" class="link">installation guide</a> to get started.</p>
</div>
<div>
<p>Read the <a href="#">installation guide</a> to get started.</p>
</div>
Recoloring
Set --secondary on any ancestor to change links in that subtree.
<div class="prose">
<p class="retheme" style="--secondary: teal">A <a href="#" class="link">teal link</a> inside a scoped block.</p>
</div>
<div>
<p class="retheme" style="--secondary: teal">A <a href="#">teal link</a> inside a scoped block.</p>
</div>
Unstyled links
<a href="#" class="semantic">No accent color, no underline</a>
<a href="#" class="semantic">No accent color, no underline</a>
.semantic exists in both builds. Note that it unsets every property,
including the focus ring, so leave it off anything the keyboard needs to reach.
Composition
Common ways to put this together with other components. The general rules are on Composition.
Links in a footer
A column of site links, and a line of contact links. Links navigate, so there is no button here.
<footer>
<hr class="divider" />
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); gap: var(--padding)">
<div>
<strong>Studio name</strong>
<p class="text-secondary">A short line about what you do.</p>
<div class="flex">
<a href="#" class="link">Email</a>
<a href="#" class="link">Social</a>
</div>
</div>
<nav class="flex" style="flex-direction: column; gap: calc(var(--padding) / 4)">
<a href="#" class="link">Work</a>
<a href="#" class="link">Writing</a>
<a href="#" class="link">About</a>
<a href="#" class="link">Contact</a>
</nav>
</div>
</footer>
- Layout: a column of links is
.flexturned on its side, with the gap cut to a quarter of--paddingso it reads as one list. - Surface: a
.dividerseparates the footer without boxing it in.
A whole card as a link
When a card has one destination, the card is the link. .semantic strips the anchor's own styling, and the title takes .link so the card still looks clickable.
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); gap: var(--padding)">
<a href="#" class="semantic card prose">
<h3 class="link">Project one</h3>
<p>What it was, in a sentence.</p>
</a>
<a href="#" class="semantic card prose">
<h3 class="link">Project two</h3>
<p>What it was, in a sentence.</p>
</a>
</div>
- Actions: one anchor per card. A second link inside it would be a nested anchor, which HTML does not allow.
- Layout: a grid lays each anchor out as a block. Outside a grid or flex row, give the anchor
display: block, because.semanticunsets it to inline.