Button

A native button for an action: submit, open, delete. Six variants and eight sizes, in the look of the app's style, with room for icons and a spinner. In a form it submits only when told to; to go somewhere, use a Link.

Buttons & ActionsExperimental

Usage

import { Component, ViewEncapsulation } from '@angular/core';import { ScButton } from '@semantic-components/ui';
@Component({  selector: 'app-button-usage-demo',  imports: [ScButton],  template: ` <button scButton>Click me</button> `,  host: { class: 'flex w-full justify-center' },  encapsulation: ViewEncapsulation.None,})export class ButtonUsageDemo {}

Anatomy

One part, on a native button. An icon may go at either side, marked with its side; a spinner in place of the first while it is busy.

import { ScButton } from '@semantic-components/ui';
<button scButton>  <svg data-icon="inline-start"></svg>  Label  <svg data-icon="inline-end"></svg></button>

Cursor

Buttons keep the default cursor, as native buttons and Tailwind do: a pointer is for links. To show one on buttons anyway, add to your global styles: button:not(:disabled) { cursor: pointer; }.

Groups

Buttons are joined with a Control Group (shadcn's Button Group): side by side or stacked, with a separator, as a split button, with a menu or a popover — the Group examples below. Buttons that toggle a state are a Toggle Group.

Examples

Size

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

Default

import { Component, ViewEncapsulation } from '@angular/core';import { ScButton } from '@semantic-components/ui';
@Component({  selector: 'app-default-button-demo',  imports: [ScButton],  template: ` <button scButton>Button</button> `,  host: { class: 'flex w-full justify-center' },  encapsulation: ViewEncapsulation.None,})

Outline

import { Component, ViewEncapsulation } from '@angular/core';import { ScButton } from '@semantic-components/ui';
@Component({  selector: 'app-outline-button-demo',  imports: [ScButton],  template: ` <button scButton variant="outline">Outline</button> `,  host: { class: 'flex w-full justify-center' },  encapsulation: ViewEncapsulation.None,})

Secondary

import { Component, ViewEncapsulation } from '@angular/core';import { ScButton } from '@semantic-components/ui';
@Component({  selector: 'app-secondary-button-demo',  imports: [ScButton],  template: ` <button scButton variant="secondary">Secondary</button> `,  host: { class: 'flex w-full justify-center' },  encapsulation: ViewEncapsulation.None,})

Ghost

import { Component, ViewEncapsulation } from '@angular/core';import { ScButton } from '@semantic-components/ui';
@Component({  selector: 'app-ghost-button-demo',  imports: [ScButton],  template: ` <button scButton variant="ghost">Ghost</button> `,  host: { class: 'flex w-full justify-center' },  encapsulation: ViewEncapsulation.None,})

Destructive

import { Component, ViewEncapsulation } from '@angular/core';import { ScButton } from '@semantic-components/ui';
@Component({  selector: 'app-destructive-button-demo',  imports: [ScButton],  template: ` <button scButton variant="destructive">Destructive</button> `,  host: { class: 'flex w-full justify-center' },  encapsulation: ViewEncapsulation.None,})

Link variant

import { Component, ViewEncapsulation } from '@angular/core';import { ScButton } from '@semantic-components/ui';
@Component({  selector: 'app-link-button-demo',  imports: [ScButton],  template: ` <button scButton variant="link">Link</button> `,  host: { class: 'flex w-full justify-center' },  encapsulation: ViewEncapsulation.None,})

Icon

import { Component, ViewEncapsulation } from '@angular/core';import { ScButton } from '@semantic-components/ui';import { SiCircleFadingArrowUpIcon } from '@semantic-icons/lucide-icons';
@Component({  selector: 'app-icon-button-demo',  imports: [ScButton, SiCircleFadingArrowUpIcon],  template: `    <button scButton variant="outline" size="icon">      <svg siCircleFadingArrowUpIcon></svg>

With Icon

import { Component, ViewEncapsulation } from '@angular/core';import { ScButton } from '@semantic-components/ui';import { SiGitBranchIcon, SiGitForkIcon } from '@semantic-icons/lucide-icons';
@Component({  selector: 'app-with-icon-button-demo',  imports: [ScButton, SiGitBranchIcon, SiGitForkIcon],  template: `    <div class="flex flex-wrap items-center gap-2">      <button scButton variant="outline" size="sm">

Rounded

import { Component, ViewEncapsulation } from '@angular/core';import { ScButton } from '@semantic-components/ui';import { SiArrowUpIcon } from '@semantic-icons/lucide-icons';
@Component({  selector: 'app-rounded-button-demo',  imports: [ScButton, SiArrowUpIcon],  template: `    <button scButton variant="outline" size="icon" class="rounded-full">      <svg siArrowUpIcon></svg>

Spinner

import { Component, ViewEncapsulation } from '@angular/core';import { ScButton, ScSpinner } from '@semantic-components/ui';import { SiLoaderCircleIcon } from '@semantic-icons/lucide-icons';
@Component({  selector: 'app-spinner-button-demo',  imports: [ScButton, ScSpinner, SiLoaderCircleIcon],  template: `    <div class="flex flex-wrap items-center gap-2">      <button scButton variant="outline" disabled>

Control Group

import { Component, ViewEncapsulation } from '@angular/core';import { ScButton, ScControlGroup } from '@semantic-components/ui';import {  SiArchiveIcon,  SiClockIcon,  SiFlagIcon,} from '@semantic-icons/lucide-icons';
@Component({  selector: 'app-group-button-demo',

Vertical Group

import { Component, ViewEncapsulation } from '@angular/core';import { ScButton, ScControlGroup } from '@semantic-components/ui';import { SiMinusIcon, SiPlusIcon } from '@semantic-icons/lucide-icons';
@Component({  selector: 'app-vertical-group-button-demo',  imports: [ScButton, ScControlGroup, SiMinusIcon, SiPlusIcon],  template: `    <div scControlGroup orientation="vertical" aria-label="Media controls">      <button scButton variant="outline" size="icon">

Group Sizes

import { Component, ViewEncapsulation } from '@angular/core';import { ScButton, ScControlGroup } from '@semantic-components/ui';import { SiPlusIcon } from '@semantic-icons/lucide-icons';
@Component({  selector: 'app-group-size-button-demo',  imports: [ScButton, ScControlGroup, SiPlusIcon],  template: `    <div class="flex flex-col items-start gap-8">      <div scControlGroup aria-label="Small">

Group Separator

import { Component, ViewEncapsulation } from '@angular/core';import {  ScButton,  ScControlGroup,  ScControlGroupSeparator,} from '@semantic-components/ui';
@Component({  selector: 'app-group-separator-button-demo',  imports: [ScButton, ScControlGroup, ScControlGroupSeparator],

Split Button

import { Component, ViewEncapsulation } from '@angular/core';import {  ScButton,  ScControlGroup,  ScControlGroupSeparator,} from '@semantic-components/ui';import { SiPlusIcon } from '@semantic-icons/lucide-icons';
@Component({  selector: 'app-split-button-demo',

Group with Menu

import { Component, ViewEncapsulation } from '@angular/core';import {  ScButton,  ScControlGroup,  ScMenu,  ScMenuContent,  ScMenuItem,  ScMenuPortal,  ScMenuProvider,  ScMenuSeparator,

Group with Popover

import { Component, ViewEncapsulation } from '@angular/core';import {  ScButton,  ScControlGroup,  ScField,  ScFieldDescription,  ScLabel,  ScPopover,  ScPopoverDescription,  ScPopoverHeader,

As Link

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

Disabled

import { Component, ViewEncapsulation } from '@angular/core';import { ScButton } from '@semantic-components/ui';
@Component({  selector: 'app-disabled-button-demo',  imports: [ScButton],  template: `    <div class="flex flex-wrap items-center gap-4">      <button scButton disabled>Default</button>      <button scButton variant="secondary" disabled>Secondary</button>

Submit

import { Component, ViewEncapsulation, signal } from '@angular/core';import { FormField, FormRoot, form, required } from '@angular/forms/signals';import {  ScButton,  ScField,  ScFieldErrors,  ScInput,  ScLabel,} from '@semantic-components/ui';

RTL

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

API reference

ScButton is a directive on a native button[scButton]: its classes are the app's style's ( provideSemanticComponents({ style }), nova by default).

InputTypeDefaultDescription
variant'default' | 'outline' | 'secondary' | 'ghost' | 'destructive' | 'link''default' Its look.
size'xs' | 'sm' | 'default' | 'lg' | 'icon-xs' | 'icon-sm' | 'icon' | 'icon-lg''default' Its height: 24, 28, 32 or 36 px; the icon sizes are squares of the same.
type'button' | 'submit' | 'reset''button' A button by default: in a form, only a submit button submits it.
disabledbooleanfalse Sets the native disabled and aria-disabled: not pressed, skipped by Tab.
softDisabledbooleanfalse With disabled: aria-disabled only — still focusable and hoverable (a tooltip can say why), never pressed. Base UI: focusableWhenDisabled; Angular Material: disabledInteractive.
classstring'' Classes merged over the style (cn: a later class wins).

ScButtonVariants ({ variant, size }) is the type of every part that styles itself as a button: a link ( a[scLink]), an alert dialog's action and cancel, a carousel's arrows, a calendar's buttons, a code block's copy… Each takes variant and size, with defaults that suit its place.