Displays an indicator showing the completion progress of a task, typically displayed as a progress bar.
import { ProgressDirective } from '@/components/ui/progress' import { Component, type OnDestroy, type OnInit } from '@angular/core' @Component({ standalone: true, selector: 'progress-demo-new-york', imports: [ProgressDirective], template: `<div ubProgress [progress]="progress" class="w-[60%]"></div>`, }) export class ProgressDemoNewYork implements OnInit, OnDestroy { progress = 10 intervalId!: NodeJS.Timeout ngOnInit(): void { this.intervalId = setTimeout(() => { this.progress = 66 }, 500) } ngOnDestroy(): void { if (this.intervalId) { clearInterval(this.intervalId) } } }
import { ProgressDirective } from '@/components/ui/progress' import { Component, type OnDestroy, type OnInit } from '@angular/core' @Component({ standalone: true, selector: 'progress-demo-default', imports: [ProgressDirective], template: `<div ubProgress [progress]="progress" class="w-[60%]"></div>`, }) export class ProgressDemoDefault implements OnInit, OnDestroy { progress = 10 intervalId!: NodeJS.Timeout ngOnInit(): void { this.intervalId = setTimeout(() => { this.progress = 66 }, 500) } ngOnDestroy(): void { if (this.intervalId) { clearInterval(this.intervalId) } } }
npx shadcn-ng@latest add progress
npm install @radix-ng/primitives
import { cn } from '@/lib/utils' import { Component, computed, input, numberAttribute } from '@angular/core' import { RdxProgressIndicatorDirective, RdxProgressRootDirective } from '@radix-ng/primitives/progress' @Component({ standalone: true, selector: 'ubProgress', imports: [RdxProgressIndicatorDirective], host: { '[class]': 'computedClass()', }, hostDirectives: [ { directive: RdxProgressRootDirective, inputs: ['rdxValue:progress', 'rdxMax:max', 'rdxValueLabel:valueLabel'], }, ], template: ` <div rdxProgressIndicator class="h-full w-full flex-1 bg-primary transition-all" [style.transform]="'translateX(-' + (100 - (progress() || 0)) + '%)'"></div> `, }) export class ProgressDirective { progress = input(0, { transform: numberAttribute, }) class = input<string>() computedClass = computed(() => cn('relative h-2 w-full overflow-hidden rounded-full bg-primary/20', this.class())) }
import { cn } from '@/lib/utils' import { Component, computed, input, numberAttribute } from '@angular/core' import { RdxProgressIndicatorDirective, RdxProgressRootDirective } from '@radix-ng/primitives/progress' @Component({ standalone: true, selector: 'ubProgress', imports: [RdxProgressIndicatorDirective], host: { '[class]': 'computedClass()', }, hostDirectives: [ { directive: RdxProgressRootDirective, inputs: ['rdxValue:progress', 'rdxMax:max', 'rdxValueLabel:valueLabel'], }, ], template: ` <div rdxProgressIndicator class="h-full w-full flex-1 bg-primary transition-all" [style.transform]="'translateX(-' + (100 - (progress() || 0)) + '%)'"></div> `, }) export class ProgressDirective { progress = input(0, { transform: numberAttribute, }) class = input<string>() computedClass = computed(() => cn('relative h-4 w-full overflow-hidden rounded-full bg-secondary', this.class())) }
import { ProgressDirective } from '@/components/ui/progress'
<div ubProgress [progress]="10"></div>