# Angular ProgressCircle Component

ProgressCircle shows the progress of a task as a ring that fills up, with the value, an icon or a count in its center, segments for steps, severities, sizes and an indeterminate mode. It is a pure SVG with no dependency.

## Basic

ProgressCircle draws the progress of a task as a ring that fills up clockwise from the top, with the value in its center. value goes from min to max , 0 and 100 by default; values outside the range are clamped. The ring is a pure SVG, rendered on the server, with no dependency.

```typescript
import { Component } from '@angular/core';
import { ProgressCircleModule } from '@exhaustive-ui/core/progresscircle';

@Component({
    template: `
        <div class="card flex flex-wrap justify-center items-center gap-8">
            <p-progress-circle [value]="25" ariaLabel="Profile completion" />
            <p-progress-circle [value]="60" ariaLabel="Course progress" />
            <p-progress-circle [value]="100" ariaLabel="Backup" />
        </div>
    `,
    standalone: true,
    imports: [ProgressCircleModule]
})
export class ProgresscircleBasicDemo {
}
```

## Value and Template

The center shows the rounded percentage of the range. With a unit other than % , it shows the value itself followed by the unit, and showValue set to false leaves the center empty. The content template replaces it with anything, such as an icon or a count: it receives the value as implicit variable, along with percent , min , max and completedSegments .

```typescript
import { Component } from '@angular/core';
import { ProgressCircleModule } from '@exhaustive-ui/core/progresscircle';
import { SvgIcon } from '@exhaustive-ui/core/icon';
import { check } from '@exhaustive-ui/icons/round';

@Component({
    template: `
        <div class="card flex flex-wrap justify-center items-center gap-8">
            <p-progress-circle [value]="420" [max]="500" unit=" MB" ariaLabel="Storage used" />
            <p-progress-circle [value]="70" [showValue]="false" ariaLabel="Profile completion" />
            <p-progress-circle [value]="3" [max]="5" ariaLabel="Lessons" ariaValueText="3 of 5 lessons">
                <ng-template #content let-value let-max="max">
                    <span>{{ value }}/{{ max }}</span>
                </ng-template>
            </p-progress-circle>
            <p-progress-circle [value]="100" severity="success" ariaLabel="Upload" ariaValueText="Complete">
                <ng-template #content let-value>
                    @if (value === 100) {
                        <svg pIcon [icon]="check" class="text-green-700 dark:text-green-400" style="width: 1.75rem; height: 1.75rem"></svg>
                    } @else {
                        <span>{{ value }}%</span>
                    }
                </ng-template>
            </p-progress-circle>
        </div>
    `,
    standalone: true,
    imports: [ProgressCircleModule, SvgIcon]
})
export class ProgresscircleValueDemo {
    check = check;
}
```

## Sizes

size set to small or large picks a preset size; any other size is set with the --p-progresscircle-size CSS variable, and the value in the center follows it. strokeWidth is the width of the ring, in percent of the size of the circle, 8 by default.

```typescript
import { Component } from '@angular/core';
import { ProgressCircleModule } from '@exhaustive-ui/core/progresscircle';

@Component({
    template: `
        <div class="card flex flex-wrap justify-center items-center gap-8">
            <p-progress-circle [value]="40" size="small" ariaLabel="Small" />
            <p-progress-circle [value]="40" ariaLabel="Default size" />
            <p-progress-circle [value]="40" size="large" ariaLabel="Large" />
            <p-progress-circle [value]="40" [strokeWidth]="14" style="--p-progresscircle-size: 8rem" ariaLabel="Custom size and stroke" />
            <p-progress-circle [value]="40" [strokeWidth]="14" [showValue]="false" style="--p-progresscircle-size: 1.5rem" ariaLabel="Inline" />
        </div>
    `,
    standalone: true,
    imports: [ProgressCircleModule]
})
export class ProgresscircleSizesDemo {
}
```

## Colors

severity colors the indicator: secondary , success , info , warn , danger or contrast , with a contrast of 3:1 or more against the background in both color schemes. color and trackColor take any CSS color, and rounded set to false draws square ends.

```typescript
import { Component } from '@angular/core';
import { ProgressCircleModule } from '@exhaustive-ui/core/progresscircle';

@Component({
    template: `
        <div class="card flex flex-col items-center gap-8">
            <div class="flex flex-wrap justify-center items-center gap-6">
                <p-progress-circle [value]="65" ariaLabel="Primary" />
                <p-progress-circle [value]="65" severity="secondary" ariaLabel="Secondary" />
                <p-progress-circle [value]="65" severity="success" ariaLabel="Success" />
                <p-progress-circle [value]="65" severity="info" ariaLabel="Info" />
                <p-progress-circle [value]="65" severity="warn" ariaLabel="Warn" />
                <p-progress-circle [value]="65" severity="danger" ariaLabel="Danger" />
                <p-progress-circle [value]="65" severity="contrast" ariaLabel="Contrast" />
            </div>
            <div class="flex flex-wrap justify-center items-center gap-6">
                <p-progress-circle [value]="65" color="#7c3aed" trackColor="color-mix(in srgb, #7c3aed, transparent 80%)" ariaLabel="Custom colors" />
                <p-progress-circle [value]="65" [rounded]="false" ariaLabel="Square ends" />
            </div>
        </div>
    `,
    standalone: true,
    imports: [ProgressCircleModule]
})
export class ProgresscircleColorsDemo {
}
```

## Segments

segments splits the ring into chunks, for steps such as 3 of 5: set max to the same number so that each step fills one segment, and give ariaValueText a sentence such as "Step 3 of 5". The value can also fill the segments in part. segmentGap is the gap between two segments, in degrees.

```typescript
import { Component, signal } from '@angular/core';
import { ButtonModule } from '@exhaustive-ui/core/button';
import { ProgressCircleModule } from '@exhaustive-ui/core/progresscircle';

@Component({
    template: `
        <div class="card flex flex-col items-center gap-6">
            <div class="flex flex-wrap justify-center items-center gap-8">
                <p-progress-circle [value]="step()" [max]="5" [segments]="5" size="large" ariaLabel="Checkout" [ariaValueText]="'Step ' + step() + ' of 5'">
                    <ng-template #content let-value let-max="max">
                        <span>{{ value }}/{{ max }}</span>
                    </ng-template>
                </p-progress-circle>
                <p-progress-circle [value]="62" [segments]="10" [segmentGap]="10" severity="success" ariaLabel="Weekly goal" />
            </div>
            <div class="flex gap-2">
                <p-button label="Previous" severity="secondary" [outlined]="true" [disabled]="step() === 0" (onClick)="step.set(step() - 1)" />
                <p-button label="Next" [disabled]="step() === 5" (onClick)="step.set(step() + 1)" />
            </div>
        </div>
    `,
    standalone: true,
    imports: [ProgressCircleModule, ButtonModule]
})
export class ProgresscircleSegmentsDemo {
    step = signal(3);
}
```

## Indeterminate

mode set to indeterminate turns an arc around the ring while the duration of the task is unknown; switch back to determinate once the progress is known. The value is hidden and aria-valuenow removed, but the content template is still shown. With reduced motion, the arc turns slowly without stretching.

```typescript
import { Component } from '@angular/core';
import { ProgressCircleModule } from '@exhaustive-ui/core/progresscircle';

@Component({
    template: `
        <div class="card flex flex-wrap justify-center items-center gap-8">
            <p-progress-circle mode="indeterminate" ariaLabel="Connecting" />
            <p-progress-circle mode="indeterminate" size="small" severity="secondary" ariaLabel="Syncing" />
        </div>
    `,
    standalone: true,
    imports: [ProgressCircleModule]
})
export class ProgresscircleIndeterminateDemo {
}
```

## Upload

The ring follows the value with a transition, disabled when the user prefers reduced motion. In this upload, each file is indeterminate while it is prepared, then shows the uploaded share; the content template replaces the value with a check mark once it is done, and a polite live region announces the end, since a progress bar is not announced when its value changes.

```typescript
import { Component, DestroyRef, inject, signal } from '@angular/core';
import { ButtonModule } from '@exhaustive-ui/core/button';
import { ProgressCircleModule } from '@exhaustive-ui/core/progresscircle';
import { SvgIcon } from '@exhaustive-ui/core/icon';
import { check } from '@exhaustive-ui/icons/round';

interface UploadFile {
    name: string;
    size: number;
    loaded: number;
    state: 'waiting' | 'preparing' | 'uploading' | 'done';
}

@Component({
    template: `
        <div class="card flex flex-col items-center gap-6">
            <ul class="flex flex-col gap-4 w-full max-w-md m-0 p-0 list-none">
                @for (file of files(); track file.name) {
                    <li class="flex items-center gap-4">
                        <p-progress-circle
                            size="small"
                            [mode]="file.state === 'preparing' ? 'indeterminate' : 'determinate'"
                            [value]="file.loaded"
                            [max]="file.size"
                            [severity]="file.state === 'done' ? 'success' : null"
                            [ariaLabel]="file.name"
                            [ariaValueText]="file.state === 'done' ? 'Uploaded' : file.state === 'waiting' ? 'Waiting' : undefined"
                        >
                            <ng-template #content let-percent="percent">
                                @if (file.state === 'done') {
                                    <svg pIcon [icon]="check" class="text-green-700 dark:text-green-400" style="width: 1.25rem; height: 1.25rem"></svg>
                                } @else if (file.state !== 'preparing') {
                                    <span>{{ round(percent) }}%</span>
                                }
                            </ng-template>
                        </p-progress-circle>
                        <div class="flex flex-col">
                            <span class="font-medium">{{ file.name }}</span>
                            <span class="text-sm text-muted-color">{{ file.loaded }} of {{ file.size }} MB</span>
                        </div>
                    </li>
                }
            </ul>
            <div class="flex gap-2">
                <p-button label="Upload" [disabled]="running()" (onClick)="start()" />
                <p-button label="Reset" severity="secondary" [outlined]="true" (onClick)="reset()" />
            </div>
            <span class="sr-only" aria-live="polite">{{ announcement() }}</span>
        </div>
    `,
    standalone: true,
    imports: [ProgressCircleModule, ButtonModule, SvgIcon]
})
export class ProgresscircleDynamicDemo {
    check = check;

    files = signal<UploadFile[]>(this.initialFiles());

    running = signal(false);

    announcement = signal('');

    private timer: ReturnType<typeof setInterval> | undefined;

    constructor() {
        inject(DestroyRef).onDestroy(() => this.stop());
    }

    start() {
        this.reset();
        this.running.set(true);
        this.files.update((files) => files.map((file) => ({ ...file, state: 'preparing' })));
        let ticks = 0;

        this.timer = setInterval(() => {
            ticks++;
            this.files.update((files) =>
                files.map((file, i) => {
                    if (file.state === 'done' || ticks < 2 + i) return file;
                    const loaded = Math.min(file.size, file.loaded + Math.ceil(file.size / (4 + i * 2)));

                    return { ...file, loaded, state: loaded >= file.size ? 'done' : 'uploading' };
                })
            );

            if (this.files().every((file) => file.state === 'done')) {
                this.stop();
                this.announcement.set('All files uploaded');
            }
        }, 700);
    }

    reset() {
        this.stop();
        this.announcement.set('');
        this.files.set(this.initialFiles());
    }

    round(value: number) {
        return Math.round(value);
    }

    private stop() {
        clearInterval(this.timer);
        this.timer = undefined;
        this.running.set(false);
    }

    private initialFiles(): UploadFile[] {
        return [
            { name: 'report.pdf', size: 12, loaded: 0, state: 'waiting' },
            { name: 'photos.zip', size: 240, loaded: 0, state: 'waiting' },
            { name: 'video.mp4', size: 860, loaded: 0, state: 'waiting' }
        ];
    }
}
```

## Accessibility

Screen Reader ProgressCircle has the progressbar role with aria-valuemin , aria-valuemax and aria-valuenow , set from min , max and the clamped value . aria-valuetext is the displayed value, such as "60%" or "420 MB"; ariaValueText replaces it with a sentence, such as "Step 3 of 5", which matters with a content template or with segments. Name every progress circle with ariaLabel or with ariaLabelledBy pointing to a visible label. The SVG ring is hidden from assistive technologies. In indeterminate mode, aria-valuenow and aria-valuetext are removed, as the WAI-ARIA progressbar role asks. A progress bar is not announced when its value changes: announce the start and the end of a long task with a polite live region, as in the upload example. The indicator of each severity keeps a contrast of 3:1 or more with the background in light and dark mode. Do not rely on the color alone: pair a success or danger color with an icon or a text. The transition of the value and the stretching of the indeterminate arc are disabled when the user prefers reduced motion.

## Progress Circle

ProgressCircle shows the progress of a task as a ring that fills up, with the value or any content in its center, steps as segments and an indeterminate mode.

### Props

| Name | Type | Default | Description |
|------|------|---------|-------------|
| dt | Object | undefined | Defines scoped design tokens of the component. |
| unstyled | boolean | undefined | Indicates whether the component should be rendered without styles. |
| pt | ProgressCirclePassThrough | undefined | Used to pass attributes to DOM elements inside the component. |
| ptOptions | PassThroughOptions | undefined | Used to configure passthrough(pt) options of the component. |
| value | number | - | Current value, between  `min`  and  `max` . Values outside the range are clamped. |
| min | number | 0 | Value of an empty ring. |
| max | number | 100 | Value of a full ring. |
| mode | ProgressCircleMode | 'determinate' | Defines the mode of the progress. |
| showValue | boolean | true | Whether to display the value in the center. The value is the rounded percentage when  `unit`  is  `%` , the value itself followed by  `unit`  otherwise. |
| unit | string | '%' | Unit appended to the value. |
| size | ProgressCircleSize | - | Preset size,  `small`  or  `large` . Any other size is set with the  `--p-progresscircle-size`  CSS variable. |
| strokeWidth | number | 8 | Width of the ring, in percent of the size of the circle, from 1 to 40. |
| severity | ProgressCircleSeverity | - | Severity, the color of the indicator. |
| color | string | - | CSS color of the indicator, in place of the severity and the design token. |
| trackColor | string | - | CSS color of the track, the empty part of the ring. |
| rounded | boolean | true | Whether the ends of the indicator are rounded. |
| segments | number | - | Splits the ring into this number of segments, for steps such as 3 of 5. Set  `max`  to the same number to fill one segment per step. |
| segmentGap | number | 6 | Gap between two segments, in degrees. |
| ariaLabel | string | - | Defines a string that labels the progress circle. |
| ariaLabelledBy | string | - | Establishes relationships between the progress circle and label(s) where its value should be one or more element IDs. |
| ariaValueText | string | - | Text read by screen readers in place of the displayed value, such as "Step 3 of 5". |

### Templates

| Name | Type | Description |
|------|------|-------------|
| content | TemplateRef<ProgressCircleContentTemplateContext> | Template of the center of the circle, in place of the value. |

## Pass Through Options

| Name | Type | Description |
|------|------|-------------|
| host | PassThroughOption<HTMLElement, I> | Used to pass attributes to the host's DOM element. |
| root | PassThroughOption<HTMLElement, I> | Used to pass attributes to the root's DOM element, the host, with the progressbar role. |
| svg | PassThroughOption<SVGSVGElement, I> | Used to pass attributes to the SVG element that draws the ring. |
| track | PassThroughOption<SVGCircleElement, I> | Used to pass attributes to the track circle, or to each track segment. |
| indicator | PassThroughOption<SVGCircleElement, I> | Used to pass attributes to the indicator circle that shows the progress, or to each filled segment. |
| label | PassThroughOption<HTMLDivElement, I> | Used to pass attributes to the element in the center that holds the value or the content template. |

## Theming

### CSS Classes

| Class | Description |
|-------|-------------|
| p-progresscircle | Class name of the root element |
| p-progresscircle-svg | Class name of the SVG element |
| p-progresscircle-track | Class name of the track |
| p-progresscircle-indicator | Class name of the indicator |
| p-progresscircle-label | Class name of the label in the center |

### Design Tokens

| Token | CSS Variable | Description |
|-------|--------------|-------------|
| progresscircle.size | --p-progresscircle-size | Size of root |
| progresscircle.transition.duration | --p-progresscircle-transition-duration | Transition duration of root |
| progresscircle.sm.size | --p-progresscircle-sm-size | Size of small size |
| progresscircle.lg.size | --p-progresscircle-lg-size | Size of large size |
| progresscircle.track.color | --p-progresscircle-track-color | Color of track |
| progresscircle.indicator.color | --p-progresscircle-indicator-color | Color of indicator |
| progresscircle.label.color | --p-progresscircle-label-color | Color of label |
| progresscircle.label.font.size | --p-progresscircle-label-font-size | Font size of label |
| progresscircle.label.font.weight | --p-progresscircle-label-font-weight | Font weight of label |
| progresscircle.secondary.color | --p-progresscircle-secondary-color | Color of secondary |
| progresscircle.success.color | --p-progresscircle-success-color | Color of success |
| progresscircle.info.color | --p-progresscircle-info-color | Color of info |
| progresscircle.warn.color | --p-progresscircle-warn-color | Color of warn |
| progresscircle.danger.color | --p-progresscircle-danger-color | Color of danger |
| progresscircle.contrast.color | --p-progresscircle-contrast-color | Color of contrast |

