Badge
A short label — a status, a count, a tag — in the look of the app's style.
Usage
import { Component, ViewEncapsulation } from '@angular/core';import { ScBadge } from '@semantic-components/ui';
@Component({ selector: 'app-badge-usage-demo', imports: [ScBadge], template: ` <div class="flex flex-wrap justify-center gap-2"> <span scBadge>Badge</span> <span scBadge variant="secondary">Secondary</span> <span scBadge variant="destructive">Destructive</span> <span scBadge variant="outline">Outline</span> </div> `, host: { class: 'flex w-full justify-center' }, encapsulation: ViewEncapsulation.None,})export class BadgeUsageDemo {}Anatomy
One directive, on a span or a div; on an a it is a link, with a hover. An icon takes data-icon="inline-start" or "inline-end": less padding on that side.
import { ScBadge } from '@semantic-components/ui';<span scBadge variant="secondary"> <svg data-icon="inline-start"></svg> Label</span>Examples
Variants
DefaultSecondaryDestructiveOutlineGhost
import { Component, ViewEncapsulation } from '@angular/core';import { ScBadge } from '@semantic-components/ui';
@Component({ selector: 'app-variants-badge-demo', imports: [ScBadge], template: ` <div class="flex flex-wrap justify-center gap-2"> <span scBadge>Default</span> <span scBadge variant="secondary">Secondary</span>With Icon
Verified Bookmark
import { Component, ViewEncapsulation } from '@angular/core';import { ScBadge } from '@semantic-components/ui';import { SiBadgeCheckIcon, SiBookmarkIcon } from '@semantic-icons/lucide-icons';
/** data-icon="inline-start" or "inline-end": less padding on that side. */@Component({ selector: 'app-icon-badge-demo', imports: [ScBadge, SiBadgeCheckIcon, SiBookmarkIcon], template: ` <div class="flex flex-wrap justify-center gap-2">With Spinner
Deleting Generating
import { Component, ViewEncapsulation } from '@angular/core';import { ScBadge, ScSpinner } from '@semantic-components/ui';import { SiLoaderCircleIcon } from '@semantic-icons/lucide-icons';
/** A spinner as the icon: data-icon on it too; it is named, a status. */@Component({ selector: 'app-spinner-badge-demo', imports: [ScBadge, ScSpinner, SiLoaderCircleIcon], template: ` <div class="flex flex-wrap justify-center gap-2">As a link
import { Component, ViewEncapsulation } from '@angular/core';import { RouterLink } from '@angular/router';import { ScBadge } from '@semantic-components/ui';import { SiArrowUpRightIcon } from '@semantic-icons/lucide-icons';
/** On an a: a link that looks like a badge, with a hover. */@Component({ selector: 'app-link-badge-demo', imports: [RouterLink, ScBadge, SiArrowUpRightIcon], template: `Custom Colors
Blue Green Sky Purple Red
import { Component, ViewEncapsulation } from '@angular/core';import { ScBadge } from '@semantic-components/ui';
/** Your own colors: classes over the style's (cn: a later class wins). */@Component({ selector: 'app-colors-badge-demo', imports: [ScBadge], template: ` <div class="flex flex-wrap justify-center gap-2"> <spanRTL
شارة موثّق مدمّرمحدد
import { Dir } from '@angular/cdk/bidi';import { Component, LOCALE_ID, ViewEncapsulation } from '@angular/core';import { ScBadge } from '@semantic-components/ui';import { SiBadgeCheckIcon } from '@semantic-icons/lucide-icons';
/** Right to left: the badges from the right, the icon at the start (right). */@Component({ selector: 'app-rtl-badge-demo', imports: [Dir, ScBadge, SiBadgeCheckIcon], template: `API reference
ScBadge — div[scBadge], span[scBadge], a[scBadge]
| Input | Type | Default | Description |
|---|---|---|---|
variant | 'default' | 'secondary' | 'destructive' | 'outline' | 'ghost' | 'link' | 'default' | Its look, from the style. |
class | string | '' | Classes merged over the style (cn: a later class wins) — your own colors. |