Button
Displays a callout for user attention.
import { Component } from '@angular/core';
import { HlmButtonDirective } from '@spartan-ng/ui-button-helm';
@Component({
selector: 'spartan-button-preview',
standalone: true,
imports: [HlmButtonDirective],
template: ` <button hlmBtn>Button</button> `,
})
export class ButtonPreviewComponent {}
Installation
npx nx g @spartan-ng/cli:ui button
ng g @spartan-ng/cli:ui button
Usage
import { HlmButtonDirective } from '@spartan-ng/ui-button-helm';
<button hlmBtn>Button</button>
Examples
Default
import { Component } from '@angular/core';
import { HlmButtonDirective } from '@spartan-ng/ui-button-helm';
@Component({
selector: 'spartan-button-preview',
standalone: true,
imports: [HlmButtonDirective],
template: ` <button hlmBtn>Button</button> `,
})
export class ButtonPreviewComponent {}
Secondary
import { Component } from '@angular/core';
import { HlmButtonDirective } from '@spartan-ng/ui-button-helm';
@Component({
selector: 'spartan-button-secondary',
standalone: true,
imports: [HlmButtonDirective],
template: `
<button hlmBtn variant='secondary'>Secondary</button> `,})
export class ButtonSecondaryComponent {}
Destructive
import { Component } from '@angular/core';
import { HlmButtonDirective } from '@spartan-ng/ui-button-helm';
@Component({
selector: 'spartan-button-destructive',
standalone: true,
imports: [HlmButtonDirective],
template: `
<button hlmBtn variant='destructive'>Destructive</button> `,})
export class ButtonDestructiveComponent {}
Outline
import { Component } from '@angular/core';
import { HlmButtonDirective } from '@spartan-ng/ui-button-helm';
@Component({
selector: 'spartan-button-outline',
standalone: true,
imports: [HlmButtonDirective],
template: `
<button hlmBtn variant='outline'>Outline</button> `,})
export class ButtonOutlineComponent {}
Ghost
import { Component } from '@angular/core';
import { HlmButtonDirective } from '@spartan-ng/ui-button-helm';
@Component({
selector: 'spartan-button-ghost',
standalone: true,
imports: [HlmButtonDirective],
template: `
<button hlmBtn variant='ghost'>Ghost</button> `,})
export class ButtonGhostComponent {}
Link
import { Component } from '@angular/core';
import { HlmButtonDirective } from '@spartan-ng/ui-button-helm';
@Component({
selector: 'spartan-button-link',
standalone: true,
imports: [HlmButtonDirective],
template: `
<button hlmBtn variant='link'>Link</button> `,})
export class ButtonLinkComponent {}
Icon
import { Component } from '@angular/core';
import { HlmButtonDirective } from '@spartan-ng/ui-button-helm';
import { HlmSpinnerComponent } from '@spartan-ng/ui-spinner-helm';
import { HlmIconComponent } from '@spartan-ng/ui-icon-helm';
import { provideIcons } from '@ng-icons/core';
import { lucideChevronRight } from '@ng-icons/lucide';
@Component({
selector: 'spartan-button-icon',
standalone: true,
imports: [HlmButtonDirective, HlmSpinnerComponent, HlmIconComponent],
providers: [provideIcons({ lucideChevronRight })],
template: ` <button hlmBtn size="icon" variant="outline"><hlm-icon size='sm' name="lucideChevronRight" /></button> `,
})
export class ButtonIconComponent {}
With Icon
import { Component } from '@angular/core';
import { HlmButtonDirective } from '@spartan-ng/ui-button-helm';
import { HlmIconComponent } from '@spartan-ng/ui-icon-helm';
import { provideIcons } from '@ng-icons/core';
import { lucideMail } from '@ng-icons/lucide';
@Component({
selector: 'spartan-button-with-icon',
standalone: true,
imports: [HlmButtonDirective, HlmIconComponent],
providers: [provideIcons({ lucideMail })],
template: `
<button hlmBtn>
<hlm-icon size="sm" class="mr-2" name="lucideMail" />
Login with Email
</button>
`,
})
export class ButtonWithIconComponent {}
Loading
import { Component } from '@angular/core';
import { HlmButtonDirective } from '@spartan-ng/ui-button-helm';
import { HlmSpinnerComponent } from '@spartan-ng/ui-spinner-helm';
import { HlmIconComponent } from '@spartan-ng/ui-icon-helm';
import { provideIcons } from '@ng-icons/core';
import { lucideLoaderCircle } from '@ng-icons/lucide';
@Component({
selector: 'spartan-button-loading',
standalone: true,
imports: [HlmButtonDirective, HlmSpinnerComponent, HlmIconComponent],
providers: [provideIcons({ lucideLoaderCircle })],
template: `
<button disabled hlmBtn><hlm-icon name="lucideLoaderCircle" size="sm" class="mr-2 animate-spin" /> Please wait</button>
`,
})
export class ButtonLoadingComponent {}
As Anchor
import { Component } from '@angular/core';
import { HlmButtonDirective } from '@spartan-ng/ui-button-helm';
@Component({
selector: 'spartan-button-anchor',
standalone: true,
imports: [HlmButtonDirective],
template: ` <a hlmBtn target='_blank' variant="link" href="https://github.com/goetzrobin/spartan"> Star on GitHub </a> `,
})
export class ButtonAnchorComponent {}