- Accordion
- Alert
- Alert Dialog
- Aspect Ratio
- Attachment
- Autocomplete
- Avatar
- Badge
- Breadcrumb
- Bubble
- Button
- Button Group
- Calendar
- Card
- Carousel
- Chart
- Checkbox
- Code Block
- Collapsible
- Combobox
- Command
- Context Menu
- Data Table
- Date Picker
- Dialog
- Drawer
- Dropdown Menu
- Empty
- Field
- Hover Card
- Input Group
- Input OTP
- Input
- Item
- Kbd
- Label
- Marker
- Menubar
- Message
- Message Scroller
- Native Select
- Navigation Menu
- Pagination
- Popover
- Progress
- Questionnaire
- Radio Group
- Resizable
- Scroll Area
- Select
- Separator
- Sheet
- Sidebar
- Skeleton
- Slider
- Sonner (Toast)
- Spinner
- Switch
- Table
- Tabs
- Textarea
- Toggle
- Toggle Group
- Tooltip
- Trace
Alert Dialog
A modal dialog that interrupts the user with important content and expects a response.
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { HlmAlertDialogImports } from '@spartan-ng/helm/alert-dialog';
import { HlmButtonImports } from '@spartan-ng/helm/button';
@Component({
selector: 'spartan-alert-dialog-preview',
imports: [HlmAlertDialogImports, HlmButtonImports],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<hlm-alert-dialog>
<button hlmAlertDialogTrigger hlmBtn variant="outline">Show Dialog</button>
<hlm-alert-dialog-content *hlmAlertDialogPortal="let ctx">
<hlm-alert-dialog-header>
<h2 hlmAlertDialogTitle>Are you absolutely sure?</h2>
<p hlmAlertDialogDescription>
This action cannot be undone. This will permanently delete your account from our servers.
</p>
</hlm-alert-dialog-header>
<hlm-alert-dialog-footer>
<button hlmAlertDialogCancel>Cancel</button>
<button hlmAlertDialogAction>Continue</button>
</hlm-alert-dialog-footer>
</hlm-alert-dialog-content>
</hlm-alert-dialog>
`,
})
export class AlertDialogPreview {}Installation
ng g @spartan-ng/cli:ui alert-dialognx g @spartan-ng/cli:ui alert-dialogUsage
import { HlmAlertDialogImports } from '@spartan-ng/helm/alert-dialog';<hlm-alert-dialog>
<button hlmAlertDialogTrigger hlmBtn variant="outline">Show Dialog</button>
<hlm-alert-dialog-content *hlmAlertDialogPortal="let ctx">
<hlm-alert-dialog-header>
<h2 hlmAlertDialogTitle>Are you absolutely sure?</h2>
<p hlmAlertDialogDescription>This action cannot be undone. This will permanently delete your account from our servers.</p>
</hlm-alert-dialog-header>
<hlm-alert-dialog-footer>
<button hlmAlertDialogCancel>Cancel</button>
<button hlmAlertDialogAction>Continue</button>
</hlm-alert-dialog-footer>
</hlm-alert-dialog-content>
</hlm-alert-dialog>Examples
Small
Use the size="sm" prop to make the alert dialog smaller.
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { HlmAlertDialogImports } from '@spartan-ng/helm/alert-dialog';
import { HlmButtonImports } from '@spartan-ng/helm/button';
@Component({
selector: 'spartan-alert-dialog-small',
imports: [HlmAlertDialogImports, HlmButtonImports],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<hlm-alert-dialog>
<button hlmAlertDialogTrigger hlmBtn variant="outline">Show Dialog</button>
<hlm-alert-dialog-content *hlmAlertDialogPortal="let ctx" size="sm">
<hlm-alert-dialog-header>
<h2 hlmAlertDialogTitle>Allow accessory to connect?</h2>
<p hlmAlertDialogDescription>Do you want to allow the USB accessory to connect to this device?</p>
</hlm-alert-dialog-header>
<hlm-alert-dialog-footer>
<button hlmAlertDialogCancel>Don't allow</button>
<button hlmAlertDialogAction>Allow</button>
</hlm-alert-dialog-footer>
</hlm-alert-dialog-content>
</hlm-alert-dialog>
`,
})
export class AlertDialogSmall {}Media
Use the hlm-alert-dialog-media component to add a media element such as an icon or image to the alert dialog.
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { NgIcon, provideIcons } from '@ng-icons/core';
import { lucideCircleFadingPlus } from '@ng-icons/lucide';
import { HlmAlertDialogImports } from '@spartan-ng/helm/alert-dialog';
import { HlmButtonImports } from '@spartan-ng/helm/button';
@Component({
selector: 'spartan-alert-dialog-media',
imports: [HlmAlertDialogImports, HlmButtonImports, NgIcon],
providers: [provideIcons({ lucideCircleFadingPlus })],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<hlm-alert-dialog>
<button hlmAlertDialogTrigger hlmBtn variant="outline">Share Project</button>
<hlm-alert-dialog-content *hlmAlertDialogPortal="let ctx">
<hlm-alert-dialog-header>
<hlm-alert-dialog-media>
<ng-icon name="lucideCircleFadingPlus" />
</hlm-alert-dialog-media>
<h2 hlmAlertDialogTitle>Share this project?</h2>
<p hlmAlertDialogDescription>Anyone with the link will be able to view and edit this project.</p>
</hlm-alert-dialog-header>
<hlm-alert-dialog-footer>
<button hlmAlertDialogCancel>Cancel</button>
<button hlmAlertDialogAction>Share</button>
</hlm-alert-dialog-footer>
</hlm-alert-dialog-content>
</hlm-alert-dialog>
`,
})
export class AlertDialogMedia {}Small with Media
Use the size="sm" prop to make the alert dialog smaller and the hlm-alert-dialog-media component to add a media element such as an icon or image to the alert dialog.
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { NgIcon, provideIcons } from '@ng-icons/core';
import { lucideBluetooth } from '@ng-icons/lucide';
import { HlmAlertDialogImports } from '@spartan-ng/helm/alert-dialog';
import { HlmButtonImports } from '@spartan-ng/helm/button';
@Component({
selector: 'spartan-alert-dialog-small-media',
imports: [HlmAlertDialogImports, HlmButtonImports, NgIcon],
providers: [provideIcons({ lucideBluetooth })],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<hlm-alert-dialog>
<button hlmAlertDialogTrigger hlmBtn variant="outline">Show Dialog</button>
<hlm-alert-dialog-content *hlmAlertDialogPortal="let ctx" size="sm">
<hlm-alert-dialog-header>
<hlm-alert-dialog-media>
<ng-icon name="lucideBluetooth" />
</hlm-alert-dialog-media>
<h2 hlmAlertDialogTitle>Allow accessory to connect?</h2>
<p hlmAlertDialogDescription>Do you want to allow the USB accessory to connect to this device?</p>
</hlm-alert-dialog-header>
<hlm-alert-dialog-footer>
<button hlmAlertDialogCancel>Don't allow</button>
<button hlmAlertDialogAction>Allow</button>
</hlm-alert-dialog-footer>
</hlm-alert-dialog-content>
</hlm-alert-dialog>
`,
})
export class AlertDialogSmallMedia {}Destructive
Use hlmAlertDialogAction with the variant="destructive" prop to indicate a destructive action.
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { NgIcon, provideIcons } from '@ng-icons/core';
import { lucideTrash2 } from '@ng-icons/lucide';
import { HlmAlertDialogImports } from '@spartan-ng/helm/alert-dialog';
import { HlmButtonImports } from '@spartan-ng/helm/button';
@Component({
selector: 'spartan-alert-dialog-destructive',
imports: [HlmAlertDialogImports, HlmButtonImports, NgIcon],
providers: [provideIcons({ lucideTrash2 })],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<hlm-alert-dialog>
<button hlmAlertDialogTrigger hlmBtn variant="destructive">Delete Chat</button>
<hlm-alert-dialog-content *hlmAlertDialogPortal="let ctx" size="sm">
<hlm-alert-dialog-header>
<hlm-alert-dialog-media
class="bg-destructive/10 text-destructive dark:bg-destructive/20 dark:text-destructive"
>
<ng-icon name="lucideTrash2" />
</hlm-alert-dialog-media>
<h2 hlmAlertDialogTitle>Delete chat?</h2>
<p hlmAlertDialogDescription>
This will permanently delete this chat conversation. View
<a href="#">Settings</a>
to delete any memories saved during this chat.
</p>
</hlm-alert-dialog-header>
<hlm-alert-dialog-footer>
<button hlmAlertDialogCancel>Cancel</button>
<button hlmAlertDialogAction variant="destructive">Delete</button>
</hlm-alert-dialog-footer>
</hlm-alert-dialog-content>
</hlm-alert-dialog>
`,
})
export class AlertDialogDestructive {}Dropdown Menu
Use hlmAlertDialogTriggerFor on a menu item to open an alert dialog from a dropdown menu.
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { HlmAlertDialogImports } from '@spartan-ng/helm/alert-dialog';
import { HlmButtonImports } from '@spartan-ng/helm/button';
import { HlmDropdownMenuImports } from '@spartan-ng/helm/dropdown-menu';
@Component({
selector: 'spartan-alert-dialog-dropdown',
imports: [HlmAlertDialogImports, HlmButtonImports, HlmDropdownMenuImports],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<button hlmBtn variant="outline" [hlmDropdownMenuTrigger]="menu">Open Menu</button>
<ng-template #menu>
<hlm-dropdown-menu>
<hlm-dropdown-menu-group>
<button hlmDropdownMenuItem>Edit</button>
<button hlmDropdownMenuItem>Share</button>
</hlm-dropdown-menu-group>
<hlm-dropdown-menu-separator />
<button hlmDropdownMenuItem variant="destructive" [hlmAlertDialogTriggerFor]="deleteDialog">Delete</button>
</hlm-dropdown-menu>
</ng-template>
<hlm-alert-dialog #deleteDialog="hlmAlertDialog">
<hlm-alert-dialog-content *hlmAlertDialogPortal="let ctx">
<hlm-alert-dialog-header>
<h2 hlmAlertDialogTitle>Are you absolutely sure?</h2>
<p hlmAlertDialogDescription>This action cannot be undone. This will permanently delete this item.</p>
</hlm-alert-dialog-header>
<hlm-alert-dialog-footer>
<button hlmAlertDialogCancel>Cancel</button>
<button hlmAlertDialogAction variant="destructive">Delete</button>
</hlm-alert-dialog-footer>
</hlm-alert-dialog-content>
</hlm-alert-dialog>
`,
})
export class AlertDialogDropdown {}RTL
To enable RTL support in spartan-ng, see the RTL configuration guide.
import { ChangeDetectionStrategy, Component, computed, inject } from '@angular/core';
import { NgIcon, provideIcons } from '@ng-icons/core';
import { lucideBluetooth } from '@ng-icons/lucide';
import { TranslateService, Translations } from '@spartan-ng/app/app/shared/translate.service';
import { HlmAlertDialogImports } from '@spartan-ng/helm/alert-dialog';
import { HlmButtonImports } from '@spartan-ng/helm/button';
@Component({
selector: 'spartan-alert-dialog-rtl',
imports: [HlmAlertDialogImports, HlmButtonImports, NgIcon],
providers: [provideIcons({ lucideBluetooth })],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<div class="flex gap-4" [dir]="_dir()">
<hlm-alert-dialog>
<button hlmAlertDialogTrigger hlmBtn variant="outline">{{ _t()['showDialog'] }}</button>
<hlm-alert-dialog-content *hlmAlertDialogPortal="let ctx" [dir]="_dir()">
<hlm-alert-dialog-header>
<h2 hlmAlertDialogTitle>{{ _t()['title'] }}</h2>
<p hlmAlertDialogDescription>
{{ _t()['description'] }}
</p>
</hlm-alert-dialog-header>
<hlm-alert-dialog-footer>
<button hlmAlertDialogCancel>{{ _t()['cancel'] }}</button>
<button hlmAlertDialogAction>{{ _t()['continue'] }}</button>
</hlm-alert-dialog-footer>
</hlm-alert-dialog-content>
</hlm-alert-dialog>
<hlm-alert-dialog>
<button hlmAlertDialogTrigger hlmBtn variant="outline">{{ _t()['showDialogSm'] }}</button>
<hlm-alert-dialog-content *hlmAlertDialogPortal="let ctx" size="sm" [dir]="_dir()">
<hlm-alert-dialog-header>
<hlm-alert-dialog-media>
<ng-icon name="lucideBluetooth" />
</hlm-alert-dialog-media>
<h2 hlmAlertDialogTitle>{{ _t()['smallTitle'] }}</h2>
<p hlmAlertDialogDescription>
{{ _t()['smallDescription'] }}
</p>
</hlm-alert-dialog-header>
<hlm-alert-dialog-footer>
<button hlmAlertDialogCancel>{{ _t()['dontAllow'] }}</button>
<button hlmAlertDialogAction>{{ _t()['allow'] }}</button>
</hlm-alert-dialog-footer>
</hlm-alert-dialog-content>
</hlm-alert-dialog>
</div>
`,
})
export class AlertDialogRtl {
private readonly _language = inject(TranslateService).language;
private readonly _translations: Translations = {
en: {
dir: 'ltr',
values: {
showDialog: 'Show Dialog',
showDialogSm: 'Show Dialog (sm)',
title: 'Are you absolutely sure?',
description: 'This action cannot be undone. This will permanently delete your account from our servers.',
cancel: 'Cancel',
continue: 'Continue',
smallTitle: 'Allow accessory to connect?',
smallDescription: 'Do you want to allow the USB accessory to connect to this device?',
dontAllow: "Don't allow",
allow: 'Allow',
},
},
ar: {
dir: 'rtl',
values: {
showDialog: 'إظهار الحوار',
showDialogSm: 'إظهار الحوار (صغير)',
title: 'هل أنت متأكد تمامًا؟',
description: 'لا يمكن التراجع عن هذا الإجراء. سيؤدي هذا إلى حذف حسابك نهائيًا من خوادمنا.',
cancel: 'إلغاء',
continue: 'متابعة',
smallTitle: 'السماح للملحق بالاتصال؟',
smallDescription: 'هل تريد السماح لملحق USB بالاتصال بهذا الجهاز؟',
dontAllow: 'عدم السماح',
allow: 'السماح',
},
},
he: {
dir: 'rtl',
values: {
showDialog: 'הצג דיאלוג',
showDialogSm: 'הצג דיאלוג (קטן)',
title: 'האם אתה בטוח לחלוטין?',
description: 'פעולה זו לא ניתנת לביטול. זה ימחק לצמיתות את החשבון שלך מהשרתים שלנו.',
cancel: 'ביטול',
continue: 'המשך',
smallTitle: 'לאפשר להתקן להתחבר?',
smallDescription: 'האם אתה רוצה לאפשר להתקן USB להתחבר למכשיר זה?',
dontAllow: 'אל תאפשר',
allow: 'אפשר',
},
},
};
private readonly _translation = computed(() => this._translations[this._language()]);
protected readonly _t = computed(() => this._translation().values);
protected readonly _dir = computed(() => this._translation().dir);
}Brain API
BrnAlertDialogContent
Selector: [brnAlertDialogContent]
ExportAs: brnAlertDialogContent
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| class | string | null | undefined | undefined | - |
| context | T | undefined | undefined | - |
BrnAlertDialogDescription
Selector: [brnAlertDialogDescription]
ExportAs: brnAlertDialogDescription
BrnAlertDialogOverlay
Selector: [brnAlertDialogOverlay],brn-alert-dialog-overlay
ExportAs: brnAlertDialogOverlay
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| class | string | null | undefined | undefined | - |
BrnAlertDialogTitle
Selector: [brnAlertDialogTitle]
ExportAs: brnAlertDialogTitle
BrnAlertDialogTrigger
Selector: button[brnAlertDialogTrigger],button[brnAlertDialogTriggerFor]
ExportAs: brnAlertDialogTrigger
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| brnAlertDialogTriggerFor | BrnAlertDialog | undefined | - | - |
| id | string | `brn-dialog-trigger-${++triggerIdSequence}` | - |
| type | 'button' | 'submit' | 'reset' | 'button' | - |
| brnDialogTriggerFor | BrnDialog | undefined | undefined | - |
BrnAlertDialog
Selector: [brnAlertDialog],brn-alert-dialog
ExportAs: brnAlertDialog
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| id | string | nextBrnDialogId() | - |
| state | BrnDialogState | null | null | - |
| role | BrnDialogOptions['role'] | this._defaultOptions.role | - |
| hasBackdrop | boolean | this._defaultOptions.hasBackdrop | - |
| positionStrategy | BrnDialogOptions['positionStrategy'] | this._defaultOptions.positionStrategy | - |
| scrollStrategy | BrnDialogOptions['scrollStrategy'] | 'close' | 'reposition' | null | this._defaultOptions.scrollStrategy | - |
| restoreFocus | BrnDialogOptions['restoreFocus'] | this._defaultOptions.restoreFocus | - |
| closeOnOutsidePointerEvents | boolean | this._defaultOptions.closeOnOutsidePointerEvents | - |
| attachTo | BrnDialogOptions['attachTo'] | this._defaultOptions.attachTo | - |
| attachPositions | BrnDialogOptions['attachPositions'] | this._defaultOptions.attachPositions | - |
| autoFocus | BrnDialogOptions['autoFocus'] | this._defaultOptions.autoFocus | - |
| disableClose | boolean | this._defaultOptions.disableClose | - |
| aria-describedby | BrnDialogOptions['ariaDescribedBy'] | this._defaultOptions.ariaDescribedBy | - |
| aria-labelledby | BrnDialogOptions['ariaLabelledBy'] | this._defaultOptions.ariaLabelledBy | - |
| aria-label | BrnDialogOptions['ariaLabel'] | this._defaultOptions.ariaLabel | - |
| aria-modal | boolean | this._defaultOptions.ariaModal | - |
Outputs
| Prop | Type | Default | Description |
|---|---|---|---|
| closed | TResult | - | - |
| stateChanged | BrnDialogState | - | - |
Helm API
HlmAlertDialogAction
Selector: button[hlmAlertDialogAction]
ExportAs: hlmAlertDialogAction
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| type | 'button' | 'submit' | 'reset' | 'button' | - |
| variant | ButtonVariants['variant'] | this._config.variant | - |
| size | ButtonVariants['size'] | this._config.size | - |
HlmAlertDialogCancel
Selector: button[hlmAlertDialogCancel]
ExportAs: hlmAlertDialogCancel
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| type | 'button' | 'submit' | 'reset' | 'button' | - |
| variant | ButtonVariants['variant'] | this._config.variant | - |
| size | ButtonVariants['size'] | this._config.size | - |
HlmAlertDialogContent
Selector: [hlmAlertDialogContent],hlm-alert-dialog-content
ExportAs: hlmAlertDialogContent
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| size | 'sm' | 'default' | 'default' | - |
HlmAlertDialogDescription
Selector: [hlmAlertDialogDescription]
ExportAs: hlmAlertDialogDescription
HlmAlertDialogFooter
Selector: [hlmAlertDialogFooter],hlm-alert-dialog-footer
ExportAs: hlmAlertDialogFooter
HlmAlertDialogHeader
Selector: [hlmAlertDialogHeader],hlm-alert-dialog-header
ExportAs: hlmAlertDialogHeader
HlmAlertDialogMedia
Selector: [hlmAlertDialogMedia],hlm-alert-dialog-media
ExportAs: hlmAlertDialogMedia
HlmAlertDialogOverlay
Selector: [hlmAlertDialogOverlay],hlm-alert-dialog-overlay
ExportAs: hlmAlertDialogOverlay
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| class | ClassValue | '' | - |
HlmAlertDialogPortal
Selector: [hlmAlertDialogPortal]
ExportAs: hlmAlertDialogPortal
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| context | T | undefined | undefined | - |
| class | string | null | undefined | undefined | - |
HlmAlertDialogTitle
Selector: [hlmAlertDialogTitle]
ExportAs: hlmAlertDialogTitle
HlmAlertDialogTrigger
Selector: button[hlmAlertDialogTrigger],button[hlmAlertDialogTriggerFor]
ExportAs: hlmAlertDialogTrigger
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| id | string | `brn-dialog-trigger-${++triggerIdSequence}` | - |
| hlmAlertDialogTriggerFor | BrnAlertDialog | undefined | - | - |
| type | 'button' | 'submit' | 'reset' | 'button' | - |
HlmAlertDialog
Selector: hlm-alert-dialog
ExportAs: hlmAlertDialog
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| id | string | nextBrnDialogId() | - |
| state | BrnDialogState | null | null | - |
| role | BrnDialogOptions['role'] | this._defaultOptions.role | - |
| hasBackdrop | boolean | this._defaultOptions.hasBackdrop | - |
| positionStrategy | BrnDialogOptions['positionStrategy'] | this._defaultOptions.positionStrategy | - |
| scrollStrategy | BrnDialogOptions['scrollStrategy'] | 'close' | 'reposition' | null | this._defaultOptions.scrollStrategy | - |
| restoreFocus | BrnDialogOptions['restoreFocus'] | this._defaultOptions.restoreFocus | - |
| closeOnOutsidePointerEvents | boolean | this._defaultOptions.closeOnOutsidePointerEvents | - |
| attachTo | BrnDialogOptions['attachTo'] | this._defaultOptions.attachTo | - |
| attachPositions | BrnDialogOptions['attachPositions'] | this._defaultOptions.attachPositions | - |
| autoFocus | BrnDialogOptions['autoFocus'] | this._defaultOptions.autoFocus | - |
| disableClose | boolean | this._defaultOptions.disableClose | - |
| aria-describedby | BrnDialogOptions['ariaDescribedBy'] | this._defaultOptions.ariaDescribedBy | - |
| aria-labelledby | BrnDialogOptions['ariaLabelledBy'] | this._defaultOptions.ariaLabelledBy | - |
| aria-label | BrnDialogOptions['ariaLabel'] | this._defaultOptions.ariaLabel | - |
| aria-modal | boolean | this._defaultOptions.ariaModal | - |
Outputs
| Prop | Type | Default | Description |
|---|---|---|---|
| closed | TResult | - | - |
| stateChanged | BrnDialogState | - | - |
On This Page