Link
Text links in default, muted and plain styles, with a clear marker for links that open in a new tab.
Installation
bash
npx bootcn add linkbash
pnpm dlx bootcn add linkbash
yarn dlx bootcn add linkbash
bunx --bun bootcn add linkThe CLI also installs the design tokens and these components: none. It prints the <link> and <script> tags to add to your layout.
Usage
Use bootcn-link for links in text, --muted for secondary links (footers, legal), --plain for lists of links. For links that open a new tab, add target="_blank" rel="noopener", the icon and the hidden "(opens in a new tab)" text.
Accessibility
- Links in text are underlined, so they do not rely on color (WCAG 1.4.1).
- A new-tab link says so to screen readers and shows an icon to everyone.
- Focus shows the same ring as buttons.
Dependencies
- Bootstrap 5.3+ CSS.
themes/tokens/tokens.css.
Source
The exact files the CLI installs (link@1.0.0). View on GitHub · Report an issue
html
<p>Read the <a class="bootcn-link" href="#install">installation guide</a> before you start.</p>
<p><a class="bootcn-link bootcn-link--muted" href="#privacy">Privacy policy</a></p>
<p><a class="bootcn-link bootcn-link--plain" href="#changelog">What changed in this release</a></p>
<p class="mb-0">
<a class="bootcn-link" href="https://example.com" target="_blank" rel="noopener">
Example documentation
<svg
class="bootcn-icon bootcn-link__external"
width="16"
height="16"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
focusable="false"
>
<path d="M15 3h6v6" />
<path d="M10 14 21 3" />
<path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6" />
</svg>
<span class="visually-hidden">(opens in a new tab)</span>
</a>
</p>css
.bootcn-link {
color: var(--bootcn-foreground);
font-weight: 500;
text-decoration: underline;
text-decoration-thickness: 1px;
text-underline-offset: 4px;
transition: text-decoration-color var(--bootcn-transition);
}
.bootcn-link:hover {
text-decoration-thickness: 2px;
}
.bootcn-link:focus-visible {
border-radius: var(--bootcn-radius-sm);
outline: 0;
box-shadow: var(--bootcn-focus-ring);
}
.bootcn-link--muted {
color: var(--bootcn-muted-foreground);
}
.bootcn-link--muted:hover {
color: var(--bootcn-foreground);
}
/* Plain: no underline at rest. Use only where links are obviously links
(navigation lists), never inside running text. */
.bootcn-link--plain {
text-decoration: none;
}
.bootcn-link--plain:hover {
text-decoration: underline;
}
.bootcn-link__external {
width: 0.875em;
height: 0.875em;
margin-left: 0.125em;
vertical-align: -0.0625em;
}
