Link

A link: it goes somewhere, so it stays a link — opened in a new tab, copied, announced as a link. A link in text by default — underlined, the text's colour and size — or a button's look (variant).

Buttons & ActionsExperimental

Usage

import { Component, ViewEncapsulation } from '@angular/core';import { ScLink } from '@semantic-components/ui';
@Component({  selector: 'app-link-usage-demo',  imports: [ScLink],  template: `    <a scLink variant="button" href="/docs/components/button">Go to Button</a>  `,  host: { class: 'flex w-full justify-center' },  encapsulation: ViewEncapsulation.None,})export class LinkUsageDemo {}

Anatomy

One part, on a native link: its href (or routerLink) is yours, and it needs one: the link never writes or invents one, and an <a> without an address is not a link (not focusable, not announced as one). For an action, use a button. An icon may go at either side, marked with its side.

import { ScLink } from '@semantic-components/ui';
<a scLink variant="button" href="…">  <svg data-icon="inline-start"></svg>  Label  <svg data-icon="inline-end"></svg></a>

Examples

In text

Read the Button docs before you style a link as one.

By continuing, you agree to our Terms of Service and Privacy Policy.

import { Component, ViewEncapsulation } from '@angular/core';import { ScLink } from '@semantic-components/ui';
/** A link in a sentence: underlined, in the text's colour and size. */@Component({  selector: 'app-in-text-link-demo',  imports: [ScLink],  template: `    <div class="max-w-md space-y-4 text-sm">      <p>

Variants

import { Component, ViewEncapsulation } from '@angular/core';import { ScLink } from '@semantic-components/ui';
@Component({  selector: 'app-variants-link-demo',  imports: [ScLink],  template: `    <div class="flex flex-wrap items-center gap-2">      <a scLink href="/docs/components/tabs">Default</a>      <a scLink variant="link" href="/docs/components/toggle"

Size

import { Component, ViewEncapsulation } from '@angular/core';import { ScLink } from '@semantic-components/ui';import { SiArrowUpRightIcon } from '@semantic-icons/lucide-icons';
@Component({  selector: 'app-size-link-demo',  imports: [ScLink, SiArrowUpRightIcon],  template: `    <div class="flex flex-wrap items-center gap-2">      <a

With Icon

import { Component, ViewEncapsulation } from '@angular/core';import { ScLink } from '@semantic-components/ui';import {  SiArrowLeftIcon,  SiArrowRightIcon,} from '@semantic-icons/lucide-icons';
@Component({  selector: 'app-with-icon-link-demo',  imports: [ScLink, SiArrowLeftIcon, SiArrowRightIcon],

Router Link

import { Component, ViewEncapsulation } from '@angular/core';import { RouterLink } from '@angular/router';import { ScLink } from '@semantic-components/ui';
@Component({  selector: 'app-router-link-demo',  imports: [ScLink, RouterLink],  template: `    <a scLink variant="outline" routerLink="/docs/components/button">      Go to Button

External

import { Component, ViewEncapsulation } from '@angular/core';import { ScLink } from '@semantic-components/ui';import { SiExternalLinkIcon } from '@semantic-icons/lucide-icons';
@Component({  selector: 'app-external-link-demo',  imports: [ScLink, SiExternalLinkIcon],  template: `    <a      scLink

Disabled

import { Component, ViewEncapsulation } from '@angular/core';import { RouterLink } from '@angular/router';import { ScLink } from '@semantic-components/ui';
@Component({  selector: 'app-disabled-link-demo',  imports: [ScLink, RouterLink],  template: `    <div class="flex flex-wrap items-center gap-2">      <a scLink variant="button" href="/docs/components/button" disabled

RTL

import { Dir } from '@angular/cdk/bidi';import { Component, LOCALE_ID, ViewEncapsulation } from '@angular/core';import { ScLink } from '@semantic-components/ui';import {  SiArrowLeftIcon,  SiArrowRightIcon,} from '@semantic-icons/lucide-icons';
@Component({  selector: 'app-rtl-link-demo',

API reference

ScLink is a directive on a native a[scLink]: in text (the default), its classes are the style's link (its corners and focus ring); in a button's look, the style's button, as scButton's. Its address is the link's own: href, or routerLink.

InputTypeDefaultDescription
variant'default' | 'link' | 'button' | 'outline' | 'secondary' | 'ghost' | 'destructive''default' Its look: a link in text (default), or a button's, inherited from the Button — link the Button's link variant (its box, for a link among buttons), button the primary one, or outline, secondary, ghost, destructive.
size'xs' | 'sm' | 'default' | 'lg' | 'icon-xs' | 'icon-sm' | 'icon' | 'icon-lg''default' A button look's size: the button's sizes. A link in text takes the size of its text.
disabledbooleanfalse Not followed by any means (click, Enter, middle-click, routerLink); out of the tab order; announced as a dimmed link (aria-disabled).
classstring'' Classes merged over the style (cn: a later class wins).