- 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
Progress
Displays an indicator showing the completion progress of a task, typically displayed as a progress bar.
import { Component, type OnInit } from '@angular/core';
import { HlmProgressImports } from '@spartan-ng/helm/progress';
@Component({
selector: 'spartan-progress-preview',
imports: [HlmProgressImports],
template: `
<hlm-progress class="w-80" [value]="value">
<hlm-progress-indicator />
</hlm-progress>
`,
})
export class ProgressPreview implements OnInit {
public value = 15;
ngOnInit() {
setTimeout(() => (this.value = 65), 2000);
}
}Installation
ng g @spartan-ng/cli:ui progressnx g @spartan-ng/cli:ui progressimport { OVERLAY_DEFAULT_CONFIG } from '@angular/cdk/overlay';
import { brnClasses, type BrnClassesOptions } from '@spartan-ng/brain/core';
import { cn, type ClassValue } from 'cn';
import { createCn } from 'cn/config';
import { makeEnvironmentProviders, type EnvironmentProviders } from '@angular/core';
import { provideSpartanHlm } from '@spartan-ng/helm/utils';
/**
* Merges class values and resolves Tailwind CSS conflicts.
*
* To customize the merge (e.g. register custom theme values), create your own instance:
*
* @example
* ```ts
*
*
* export const hlm = createCn({
* extend: { classGroups: { 'font-size': [{ text: ['hero'] }] } },
* });
* ```
*/
export const hlm = cn;
/**
* This function dynamically adds and removes classes for a given element without requiring
* the a class binding (e.g. `[class]="..."`) which may interfere with other class bindings.
* The classes are merged with `hlm`.
*/
export function classes(computed: () => ClassValue[] | string, options: Omit<BrnClassesOptions, 'merge'> = {}) {
brnClasses(computed, { ...options, merge: hlm });
}
/**
* Provides default configuration for Spartan Helm components.
*
* This utility configures the Angular CDK overlay to disable the `usePopover`
* behavior introduced in Angular 21, which causes CDK overlay-based components
* (sheets, dialogs, tooltips, etc.) to render above `position: fixed` elements
* like `<hlm-toaster>`.
*
* @returns {EnvironmentProviders} Environment providers to be added to the application config.
*
* @example
* ```ts
* // app.config.ts
*
*
* export const appConfig: ApplicationConfig = {
* providers: [
* provideSpartanHlm(),
* // ... other providers
* ],
* };
* ```
*/
export function provideSpartanHlm(): EnvironmentProviders {
return makeEnvironmentProviders([
{
provide: OVERLAY_DEFAULT_CONFIG,
useValue: { usePopover: false },
},
]);
}import { BrnProgress, BrnProgressIndicator, injectBrnProgress } from '@spartan-ng/brain/progress';
import { Directionality } from '@angular/cdk/bidi';
import { Directive, computed, inject } from '@angular/core';
import { classes } from '@spartan-ng/helm/utils';
@Directive({
selector: '[hlmProgressIndicator],hlm-progress-indicator',
exportAs: 'hlmProgressIndicator',
hostDirectives: [BrnProgressIndicator],
host: {
'data-slot': 'progress-indicator',
'[class.animate-indeterminate]': '_indeterminate()',
'[style.transform]': '_transform()',
},
})
export class HlmProgressIndicator {
private readonly _progress = injectBrnProgress();
private readonly _dir = inject(Directionality);
// Offset the indicator by the unfilled remainder. In RTL the bar fills from the inline-start
// (visually the right), so translate the opposite way to keep the fill on the correct side.
protected readonly _transform = computed(() => {
const offset = 100 - (this._progress.value() ?? 100);
return `translateX(${this._dir.valueSignal() === 'rtl' ? '' : '-'}${offset}%)`;
});
protected readonly _indeterminate = computed(
() => this._progress.value() === null || this._progress.value() === undefined,
);
constructor() {
classes(() => 'bg-primary h-full w-full flex-1 transition-all');
}
}
@Directive({
selector: 'hlm-progress,[hlmProgress]',
exportAs: 'hlmProgress',
hostDirectives: [{ directive: BrnProgress, inputs: ['value', 'max', 'getValueLabel'] }],
host: { 'data-slot': 'progress' },
})
export class HlmProgress {
constructor() {
classes(() => 'bg-muted h-1 rounded-full relative inline-flex w-full overflow-hidden');
}
}
export const HlmProgressImports = [HlmProgress, HlmProgressIndicator] as const;import { BrnProgress, BrnProgressIndicator, injectBrnProgress } from '@spartan-ng/brain/progress';
import { Directionality } from '@angular/cdk/bidi';
import { Directive, computed, inject } from '@angular/core';
import { classes } from '@spartan-ng/helm/utils';
@Directive({
selector: '[hlmProgressIndicator],hlm-progress-indicator',
exportAs: 'hlmProgressIndicator',
hostDirectives: [BrnProgressIndicator],
host: {
'data-slot': 'progress-indicator',
'[class.animate-indeterminate]': '_indeterminate()',
'[style.transform]': '_transform()',
},
})
export class HlmProgressIndicator {
private readonly _progress = injectBrnProgress();
private readonly _dir = inject(Directionality);
// Offset the indicator by the unfilled remainder. In RTL the bar fills from the inline-start
// (visually the right), so translate the opposite way to keep the fill on the correct side.
protected readonly _transform = computed(() => {
const offset = 100 - (this._progress.value() ?? 100);
return `translateX(${this._dir.valueSignal() === 'rtl' ? '' : '-'}${offset}%)`;
});
protected readonly _indeterminate = computed(
() => this._progress.value() === null || this._progress.value() === undefined,
);
constructor() {
classes(() => 'bg-primary h-full w-full flex-1 transition-all');
}
}
@Directive({
selector: 'hlm-progress,[hlmProgress]',
exportAs: 'hlmProgress',
hostDirectives: [{ directive: BrnProgress, inputs: ['value', 'max', 'getValueLabel'] }],
host: { 'data-slot': 'progress' },
})
export class HlmProgress {
constructor() {
classes(() => 'bg-muted h-1.5 rounded-full relative inline-flex w-full overflow-hidden');
}
}
export const HlmProgressImports = [HlmProgress, HlmProgressIndicator] as const;import { BrnProgress, BrnProgressIndicator, injectBrnProgress } from '@spartan-ng/brain/progress';
import { Directionality } from '@angular/cdk/bidi';
import { Directive, computed, inject } from '@angular/core';
import { classes } from '@spartan-ng/helm/utils';
@Directive({
selector: '[hlmProgressIndicator],hlm-progress-indicator',
exportAs: 'hlmProgressIndicator',
hostDirectives: [BrnProgressIndicator],
host: {
'data-slot': 'progress-indicator',
'[class.animate-indeterminate]': '_indeterminate()',
'[style.transform]': '_transform()',
},
})
export class HlmProgressIndicator {
private readonly _progress = injectBrnProgress();
private readonly _dir = inject(Directionality);
// Offset the indicator by the unfilled remainder. In RTL the bar fills from the inline-start
// (visually the right), so translate the opposite way to keep the fill on the correct side.
protected readonly _transform = computed(() => {
const offset = 100 - (this._progress.value() ?? 100);
return `translateX(${this._dir.valueSignal() === 'rtl' ? '' : '-'}${offset}%)`;
});
protected readonly _indeterminate = computed(
() => this._progress.value() === null || this._progress.value() === undefined,
);
constructor() {
classes(() => 'bg-primary h-full w-full flex-1 transition-all');
}
}
@Directive({
selector: 'hlm-progress,[hlmProgress]',
exportAs: 'hlmProgress',
hostDirectives: [{ directive: BrnProgress, inputs: ['value', 'max', 'getValueLabel'] }],
host: { 'data-slot': 'progress' },
})
export class HlmProgress {
constructor() {
classes(() => 'bg-muted h-1 rounded-none relative inline-flex w-full overflow-hidden');
}
}
export const HlmProgressImports = [HlmProgress, HlmProgressIndicator] as const;import { BrnProgress, BrnProgressIndicator, injectBrnProgress } from '@spartan-ng/brain/progress';
import { Directionality } from '@angular/cdk/bidi';
import { Directive, computed, inject } from '@angular/core';
import { classes } from '@spartan-ng/helm/utils';
@Directive({
selector: '[hlmProgressIndicator],hlm-progress-indicator',
exportAs: 'hlmProgressIndicator',
hostDirectives: [BrnProgressIndicator],
host: {
'data-slot': 'progress-indicator',
'[class.animate-indeterminate]': '_indeterminate()',
'[style.transform]': '_transform()',
},
})
export class HlmProgressIndicator {
private readonly _progress = injectBrnProgress();
private readonly _dir = inject(Directionality);
// Offset the indicator by the unfilled remainder. In RTL the bar fills from the inline-start
// (visually the right), so translate the opposite way to keep the fill on the correct side.
protected readonly _transform = computed(() => {
const offset = 100 - (this._progress.value() ?? 100);
return `translateX(${this._dir.valueSignal() === 'rtl' ? '' : '-'}${offset}%)`;
});
protected readonly _indeterminate = computed(
() => this._progress.value() === null || this._progress.value() === undefined,
);
constructor() {
classes(() => 'bg-primary h-full w-full flex-1 transition-all');
}
}
@Directive({
selector: 'hlm-progress,[hlmProgress]',
exportAs: 'hlmProgress',
hostDirectives: [{ directive: BrnProgress, inputs: ['value', 'max', 'getValueLabel'] }],
host: { 'data-slot': 'progress' },
})
export class HlmProgress {
constructor() {
classes(() => 'bg-muted h-3 rounded-4xl relative inline-flex w-full overflow-hidden');
}
}
export const HlmProgressImports = [HlmProgress, HlmProgressIndicator] as const;import { BrnProgress, BrnProgressIndicator, injectBrnProgress } from '@spartan-ng/brain/progress';
import { Directionality } from '@angular/cdk/bidi';
import { Directive, computed, inject } from '@angular/core';
import { classes } from '@spartan-ng/helm/utils';
@Directive({
selector: '[hlmProgressIndicator],hlm-progress-indicator',
exportAs: 'hlmProgressIndicator',
hostDirectives: [BrnProgressIndicator],
host: {
'data-slot': 'progress-indicator',
'[class.animate-indeterminate]': '_indeterminate()',
'[style.transform]': '_transform()',
},
})
export class HlmProgressIndicator {
private readonly _progress = injectBrnProgress();
private readonly _dir = inject(Directionality);
// Offset the indicator by the unfilled remainder. In RTL the bar fills from the inline-start
// (visually the right), so translate the opposite way to keep the fill on the correct side.
protected readonly _transform = computed(() => {
const offset = 100 - (this._progress.value() ?? 100);
return `translateX(${this._dir.valueSignal() === 'rtl' ? '' : '-'}${offset}%)`;
});
protected readonly _indeterminate = computed(
() => this._progress.value() === null || this._progress.value() === undefined,
);
constructor() {
classes(() => 'bg-primary h-full w-full flex-1 transition-all');
}
}
@Directive({
selector: 'hlm-progress,[hlmProgress]',
exportAs: 'hlmProgress',
hostDirectives: [{ directive: BrnProgress, inputs: ['value', 'max', 'getValueLabel'] }],
host: { 'data-slot': 'progress' },
})
export class HlmProgress {
constructor() {
classes(() => 'bg-muted h-1 rounded-md relative inline-flex w-full overflow-hidden');
}
}
export const HlmProgressImports = [HlmProgress, HlmProgressIndicator] as const;import { BrnProgress, BrnProgressIndicator, injectBrnProgress } from '@spartan-ng/brain/progress';
import { Directionality } from '@angular/cdk/bidi';
import { Directive, computed, inject } from '@angular/core';
import { classes } from '@spartan-ng/helm/utils';
@Directive({
selector: '[hlmProgressIndicator],hlm-progress-indicator',
exportAs: 'hlmProgressIndicator',
hostDirectives: [BrnProgressIndicator],
host: {
'data-slot': 'progress-indicator',
'[class.animate-indeterminate]': '_indeterminate()',
'[style.transform]': '_transform()',
},
})
export class HlmProgressIndicator {
private readonly _progress = injectBrnProgress();
private readonly _dir = inject(Directionality);
// Offset the indicator by the unfilled remainder. In RTL the bar fills from the inline-start
// (visually the right), so translate the opposite way to keep the fill on the correct side.
protected readonly _transform = computed(() => {
const offset = 100 - (this._progress.value() ?? 100);
return `translateX(${this._dir.valueSignal() === 'rtl' ? '' : '-'}${offset}%)`;
});
protected readonly _indeterminate = computed(
() => this._progress.value() === null || this._progress.value() === undefined,
);
constructor() {
classes(() => 'bg-primary h-full w-full flex-1 transition-all');
}
}
@Directive({
selector: 'hlm-progress,[hlmProgress]',
exportAs: 'hlmProgress',
hostDirectives: [{ directive: BrnProgress, inputs: ['value', 'max', 'getValueLabel'] }],
host: { 'data-slot': 'progress' },
})
export class HlmProgress {
constructor() {
classes(() => 'bg-muted h-3 rounded-full relative inline-flex w-full overflow-hidden');
}
}
export const HlmProgressImports = [HlmProgress, HlmProgressIndicator] as const;Usage
import { HlmProgressImports } from '@spartan-ng/helm/progress';<hlm-progress value="33">
<hlm-progress-indicator />
</hlm-progress>Animation
The indeterminate animation animate-indeterminate is provided by @spartan-ng/brain/hlm-tailwind-preset.css . Here are two options for adding the animation to your project.
/* 1. default import */
@import '@spartan-ng/brain/hlm-tailwind-preset.css';
/* 2. add animate-indeterminate animation */
@theme inline {
--animate-indeterminate: indeterminate 4s ease-in-out infinite;
@keyframes indeterminate {
0% {
transform: translateX(-100%) scaleX(0.5);
}
100% {
transform: translateX(100%) scaleX(0.5);
}
}
} Adjust the animation to your needs by changing duration, easing function or keyframes by overriding the CSS variable --animate-indeterminate or the @keyframes indeterminate in your global styles.
@import '@spartan-ng/brain/hlm-tailwind-preset.css';
/* adjust animation duration */
@theme inline {
- --animate-indeterminate: indeterminate 4s ease-in-out infinite;
+ --animate-indeterminate: indeterminate 3s ease-in-out infinite;
}Examples
Indeterminate
import { Component } from '@angular/core';
import { HlmProgressImports } from '@spartan-ng/helm/progress';
@Component({
selector: 'spartan-progress-indeterminate',
imports: [HlmProgressImports],
template: `
<hlm-progress class="w-80">
<hlm-progress-indicator />
</hlm-progress>
`,
})
export class ProgressIndeterminatePreview {}RTL
To enable RTL support in spartan-ng, see the RTL configuration guide.
import { Directionality } from '@angular/cdk/bidi';
import { Component, computed, effect, inject, untracked } from '@angular/core';
import { TranslateService, Translations } from '@spartan-ng/app/app/shared/translate.service';
import { HlmLabel } from '@spartan-ng/helm/label';
import { HlmProgressImports } from '@spartan-ng/helm/progress';
@Component({
selector: 'spartan-progress-rtl-preview',
imports: [HlmLabel, HlmProgressImports],
providers: [Directionality],
host: {
class: 'grid w-full max-w-sm gap-3',
'[dir]': '_dir()',
},
template: `
<label hlmLabel>{{ _t()['downloading'] }}</label>
<hlm-progress [value]="60">
<hlm-progress-indicator />
</hlm-progress>
`,
})
export class ProgressRtlPreview {
private readonly _directionality = inject(Directionality);
private readonly _language = inject(TranslateService).language;
private readonly _translations: Translations = {
en: { dir: 'ltr', values: { downloading: 'Downloading…' } },
ar: { dir: 'rtl', values: { downloading: '…جارٍ التنزيل' } },
he: { dir: 'rtl', values: { downloading: '…מוריד' } },
};
private readonly _translation = computed(() => this._translations[this._language()]);
protected readonly _t = computed(() => this._translation().values);
protected readonly _dir = computed(() => this._translation().dir);
constructor() {
effect(() => {
const dir = this._dir();
untracked(() => this._directionality.valueSignal.set(dir));
});
}
}Brain API
BrnProgressIndicator
Selector: brn-progress-indicator
ExportAs: brnProgressIndicator
BrnProgress
Selector: brn-progress
ExportAs: brnProgress
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| value | number | null | undefined | undefined | The current progress value. |
| max | number | 100 | The maximum progress value. |
| getValueLabel | BrnProgressLabelFn | (value, max) => `${Math.round((value / max) * 100)}%` | A function that returns the label for the current progress value. |
Helm API
HlmProgressIndicator
Selector: [hlmProgressIndicator],hlm-progress-indicator
ExportAs: hlmProgressIndicator
HlmProgress
Selector: hlm-progress,[hlmProgress]
ExportAs: hlmProgress
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| value | number | null | undefined | undefined | The current progress value. |
| max | number | 100 | The maximum progress value. |
| getValueLabel | BrnProgressLabelFn | (value, max) => `${Math.round((value / max) * 100)}%` | A function that returns the label for the current progress value. |
On This Page