Skip to content
Brok UI

Loading…

No results

Meters

Open source

Single-value readouts of a fraction of a whole — an arc gauge, a circular progress ring, linear/radial usage readouts and a liquid-fill gauge.

Version
v1.2.1
Stability
stable
License
MIT
Related
Gauge
Usage Meter
Usage Gauge
Liquid Chart
2 of 5

Circular Progress — A static SVG ring progress indicator with a track, coloured arc, and optional centred percentage readout. Supports a `min` floor, an opt-in status tone and a custom inner value label. Shares its value/size vocabulary with gauge.

Preview

25%
72%
100%
Loading…
previews.components.circular-progress.default.blade.php Blade
<div class="w-full flex flex-wrap items-center justify-center gap-8">
    <div class="flex flex-col items-center gap-2">
        <x-ui.circular-progress :value="25" :size="64" :thickness="6" />
        <span class="text-sm text-muted-foreground">25%</span>
    </div>
    <div class="flex flex-col items-center gap-2">
        <x-ui.circular-progress :value="72" :size="64" :thickness="6" />
        <span class="text-sm text-muted-foreground">72%</span>
    </div>
    <div class="flex flex-col items-center gap-2">
        <x-ui.circular-progress :value="100" :size="64" :thickness="6" />
        <span class="text-sm text-muted-foreground">100%</span>
    </div>
    <div class="flex flex-col items-center gap-2">
        <x-ui.circular-progress indeterminate :size="64" :thickness="6" :show-value="false" />
        <span class="text-sm text-muted-foreground">Loading…</span>
    </div>
</div>

Installation

terminal
php artisan ui:add circular-progress

Registry contract

php artisan ui:add circular-progress writes only the files below. The CLI validates each file hash before writing and asks before it replaces a local change, unless you pass --force.

  • blade resources/views/components/ui/circular-progress.blade.php
Registry dependencies
None — installs on its own.
Packages
composer: jml/brok:^0.2

Use with AI

A brief for your coding agent: install command, usage, props, guidance and the rules. Copy it, or open a prompt about this component in an assistant.

circular-progress.md
# Brok UI: Circular Progress (`circular-progress`)

A static SVG ring progress indicator with a track, coloured arc, and optional centred percentage readout. Supports a `min` floor, an opt-in status tone and a custom inner value label. Shares its value/size vocabulary with gauge.

Brok UI is a Laravel Blade component registry. Installed components are plain Blade files the app owns.

## Install

```bash
php artisan ui:add circular-progress
```

## Usage

```blade
<div class="w-full flex flex-wrap items-center justify-center gap-8">
    <div class="flex flex-col items-center gap-2">
        <x-ui.circular-progress :value="25" :size="64" :thickness="6" />
        <span class="text-sm text-muted-foreground">25%</span>
    </div>
    <div class="flex flex-col items-center gap-2">
        <x-ui.circular-progress :value="72" :size="64" :thickness="6" />
        <span class="text-sm text-muted-foreground">72%</span>
    </div>
    <div class="flex flex-col items-center gap-2">
        <x-ui.circular-progress :value="100" :size="64" :thickness="6" />
        <span class="text-sm text-muted-foreground">100%</span>
    </div>
    <div class="flex flex-col items-center gap-2">
        <x-ui.circular-progress indeterminate :size="64" :thickness="6" :show-value="false" />
        <span class="text-sm text-muted-foreground">Loading…</span>
    </div>
</div>
```

## Props

- `value` (int, default `0`) — Current value, clamped between min and max.
- `min` (int, default `0`) — Floor of the value range.
- `max` (int, default `100`) — Ceiling of the value range.
- `size` (int, default `44`) — Outer diameter in pixels.
- `thickness` (mixed|null, default `null`) — Stroke width in pixels; the canonical name, shared with gauge.
- `stroke` (mixed|null, default `null`) — Legacy alias for thickness, kept for backward compatibility; thickness wins when both are set.
- `showValue` (bool, default `true`) — Shows the centred percentage readout.
- `indeterminate` (bool, default `false`) — Renders a fixed partial arc that spins continuously, for an unknown-duration loading state.
- `label` (mixed|null, default `null`) — Accessible name for the progressbar; required by WCAG when the consumer has not set aria-label or aria-labelledby.
- `tone` (mixed|null, default `null`) — Opt-in status colour for the arc (positive, attention, negative, neutral) instead of the default brand colour; colours what the value means, not how much of it there is.
- `valueLabel` (mixed|null, default `null`) — Replaces the numeric percent readout entirely, such as with a status word.
- `suffix` (string, default `%`) — Text appended to the percent readout when valueLabel is not set.

## Use when

- Use when trend, distribution, flow, intensity, or relationship questions are easier to answer visually than in raw numbers.
- Showing a single value as a percentage-of-completion ring, such as a task, upload or onboarding progress indicator.
- Needing a compact, static loading spinner via indeterminate.

## Avoid when

- Do not use a chart when users mainly need exact lookup or when a single metric would be clearer as text or a stat.
- The value is a fill level meant to read as a dial with min/max ticks; use gauge instead.
- Several values must compare on one axis; use chart instead.

## Anti-patterns

- Decorative charts without a meaningful question

## Rules

- Use the `<brok:circular-progress>` tag (or `<x-ui.circular-progress>`) in Blade; do not rewrite the component.
- Prefer the documented props and variants over utility-class overrides; when a utility must win, use the `!` important modifier.
- Use semantic design tokens (`bg-primary`, `text-muted-foreground`), never raw colour utilities.
- Keep the `data-slot` attributes; they are the styling and test hooks.

## Links

- Docs: https://brokui.dev/docs/components/circular-progress
- Registry JSON (files, props, contract): https://brokui.dev/r/open/circular-progress.json

Working in Claude Code, Cursor or Codex? Give the agent the whole registry through the MCP server or the Brok UI skill.

API

manifest knowledge + registry-derived coverage

Props

Props accepted by this component: name, type, default value and description.
Prop Type Default Description
value int 0 Current value, clamped between min and max.
min int 0 Floor of the value range.
max int 100 Ceiling of the value range.
size int 44 Outer diameter in pixels.
thickness mixed | null null Stroke width in pixels; the canonical name, shared with gauge.
stroke mixed | null null Legacy alias for thickness, kept for backward compatibility; thickness wins when both are set.
showValue bool true Shows the centred percentage readout.
indeterminate bool false Renders a fixed partial arc that spins continuously, for an unknown-duration loading state.
label mixed | null null Accessible name for the progressbar; required by WCAG when the consumer has not set aria-label or aria-labelledby.
tone mixed | null null Opt-in status colour for the arc (positive, attention, negative, neutral) instead of the default brand colour; colours what the value means, not how much of it there is.
valueLabel mixed | null null Replaces the numeric percent readout entirely, such as with a status word.
suffix string % Text appended to the percent readout when valueLabel is not set.

Slots

  • default — Unused; the ring renders from props only.

Data slots

Stable hooks for CSS overrides and browser tests.

circular-progress circular-progress-value

Behavior

  • Animates the arc's stroke-dashoffset when value changes, so re-rendering with a new value transitions smoothly.
  • indeterminate replaces the value-driven arc with a fixed 25% arc that spins continuously via CSS animation.
  • The inner readout's font size shrinks automatically to fit longer valueLabel text inside the ring.
  • Renders a static SVG progress ring; JS-free.
  • Declares registry capability flags: a11y, responsive, rtl, darkMode, localized, reducedMotion.

Guidance

Chart and visual analytics

Reveal a visual trend, distribution, flow, or relationship.

Use when

  • Use when trend, distribution, flow, intensity, or relationship questions are easier to answer visually than in raw numbers.
  • Showing a single value as a percentage-of-completion ring, such as a task, upload or onboarding progress indicator.
  • Needing a compact, static loading spinner via indeterminate.

Avoid when

  • Do not use a chart when users mainly need exact lookup or when a single metric would be clearer as text or a stat.
  • The value is a fill level meant to read as a dial with min/max ticks; use gauge instead.
  • Several values must compare on one axis; use chart instead.

Use instead

  • Table for exact lookup
  • Stat for a single value

Anti-patterns

  • Decorative charts without a meaningful question
Anatomy
root circular-progress-value
Theming hooks
circular-progress circular-progress-value

Accessibility

WCAG 2.2 AA Keyboard focus-visible RTL-ready Localized labels Dark mode
Keyboard
No component-owned keyboard interaction; native element behavior applies.
Focus
none
  • role="progressbar" carries aria-valuemin/aria-valuemax/aria-valuenow (the last omitted while indeterminate), so assistive technology reads the same value the ring shows.
  • Always set label, or set your own aria-label/aria-labelledby, so the progressbar has an accessible name; without either it falls back to a generic "Progress".
  • Semantic HTML and a stable data-slot attribute for styling and scripting hooks.
  • Focus-visible rings use the ring token, so keyboard focus is always visible.
  • Disabled and invalid states are conveyed to assistive tech, not by color alone.
  • Targets WCAG 2.2 AA; verify contrast in light, dark, admin and customer surfaces in the preview.
  • Labels go through __() and layout uses logical properties (ms-*, text-start), so it mirrors under dir="rtl" — flip the preview to RTL to confirm.
  • Dark mode uses the same semantic tokens under the dark class; high contrast follows forced-color system tokens.

Livewire

Safe

Livewire can update this component through forwarded wire:* attributes.

Source

The exact, editable file ui:add writes into your app. Previews render this same code; there are no preview-only components.

resources/views/components/ui/circular-progress.blade.php Blade
@props([
    'value'         => 0,
    'min'           => 0,
    'max'           => 100,
    'size'          => 44,
    // Canonical name, shared with the gauge component. `stroke` (below) is a
    // deprecated alias kept for backward compatibility.
    'thickness'     => null,
    'stroke'        => null,
    'showValue'     => true,
    'indeterminate' => false,
    // Accessible name — role="progressbar" requires one (WCAG). Skipped when the
    // consumer supplies aria-label/aria-labelledby themselves.
    'label'         => null,
    // Opt-in: colours the arc by what the value MEANS rather than how much of
    // it there is — a record 40% complete is not "40%", it is not ready. Left
    // null (default), the arc keeps today's `text-primary` colouring.
    // positive | attention | negative | neutral
    'tone'          => null,
    // Opt-in inner readout override. `valueLabel` replaces the numeric percent
    // entirely (e.g. a status word) when set; `suffix` only changes what is
    // appended to the percent (defaults to '%', so plain usage is unaffected).
    'valueLabel'    => null,
    'suffix'        => '%',
])

@php
    $needsName = $label === null && ! $attributes->has('aria-label') && ! $attributes->has('aria-labelledby');
    $sizePx  = (int) $size;
    // `thickness` wins when both are given; `stroke` keeps old markup working.
    $strokeW = (int) ($thickness ?? $stroke ?? 4);
    $cx      = $sizePx / 2;
    $cy      = $sizePx / 2;
    $r       = ($sizePx - $strokeW) / 2;

    $circumference = 2 * M_PI * $r;
    $min = (float) $min;
    $max = (float) $max;

    if ($indeterminate) {
        // Fixed 25 % partial arc for the indeterminate spinner.
        $dashOffset = $circumference * 0.75;
    } else {
        $value      = max($min, min((float) $value, $max));
        $span       = ($max - $min) != 0 ? ($max - $min) : 1;
        $fraction   = ($value - $min) / $span;
        $dashOffset = $circumference * (1 - $fraction);
        $percent    = (int) round($fraction * 100);
    }

    // Tone is independent of the value: a caller opts in with one of these four
    // words, or leaves it unset and gets the original brand-coloured arc. Same
    // `-text` status tokens `stat` uses for its tone map, so a ring and a KPI
    // tile in the same screen agree on what "positive"/"negative" look like.
    // The readout must sit inside the ring, so its size follows the INNER
    // diameter (outer size minus both stroke widths) and the label length —
    // "100%" at size 64 / stroke 6 has 52px to live in, not 64. The width
    // estimate uses ~0.6em per tabular digit and fills at most 72% of the
    // inner diameter so the digits sit clear of the arc; the height cap keeps
    // short labels from ballooning.
    $inner = max(8, $sizePx - 2 * $strokeW);
    $readout = $indeterminate ? '' : ($valueLabel ?? ($percent.$suffix));
    $chars = max(1, mb_strlen($readout));
    $valueFontSize = (int) floor(min($inner * 0.34, ($inner * 0.72) / ($chars * 0.6)));
    $valueFontSize = max(9, $valueFontSize);

    $validTones = ['positive', 'attention', 'negative', 'neutral'];
    $toneClass = in_array($tone, $validTones, true) ? match ($tone) {
        'positive' => 'text-success-text',
        'attention' => 'text-warning-text',
        'negative' => 'text-destructive-text',
        default => 'text-muted-foreground', // neutral
    } : null;
@endphp

<div
    data-slot="circular-progress"
    @if ($toneClass !== null) data-tone="{{ $tone }}" @endif
    role="progressbar"
    aria-valuemin="{{ $min }}"
    aria-valuemax="{{ $max }}"
    @if ($label !== null) aria-label="{{ $label }}" @elseif ($needsName) aria-label="{{ __('Progress') }}" @endif
    @unless ($indeterminate) aria-valuenow="{{ $value }}" @endunless
    {{ $attributes->merge(['class' => 'relative inline-flex items-center justify-center']) }}
    style="width: {{ $sizePx }}px; height: {{ $sizePx }}px;"
>
    <svg
        width="{{ $sizePx }}"
        height="{{ $sizePx }}"
        viewBox="0 0 {{ $sizePx }} {{ $sizePx }}"
        fill="none"
        aria-hidden="true"
        @class(['motion-safe:animate-spin' => $indeterminate])
    >
        {{-- Track --}}
        <circle
            class="text-muted"
            cx="{{ $cx }}"
            cy="{{ $cy }}"
            r="{{ $r }}"
            stroke="currentColor"
            stroke-width="{{ $strokeW }}"
        />
        {{-- Arc --}}
        <circle
            class="{{ $toneClass ?? 'text-primary' }} transition-[stroke-dashoffset] duration-500 ease-out motion-reduce:transition-none"
            cx="{{ $cx }}"
            cy="{{ $cy }}"
            r="{{ $r }}"
            stroke="currentColor"
            stroke-width="{{ $strokeW }}"
            stroke-linecap="round"
            transform="rotate(-90 {{ $cx }} {{ $cy }})"
            stroke-dasharray="{{ $circumference }}"
            stroke-dashoffset="{{ $dashOffset }}"
        />
    </svg>

    @if ($showValue && !$indeterminate)
        {{-- `text-foreground` on purpose, even when `tone` is set: the arc
             already carries the tone, and colouring the number too makes a
             negative row shout twice. --}}
        <span
            data-slot="circular-progress-value"
            @class([
                'absolute text-foreground tabular-nums',
                'max-w-full truncate px-1 text-center' => $valueLabel !== null,
            ])
            style="font-size: {{ $valueFontSize }}px; line-height: 1;"
            aria-hidden="true"
        >{{ $readout }}</span>
    @endif
</div>

Ownership & lifecycle

Owner, release state, review evidence and adoption for this item.
Owner
Platform UI (@JoshJML)
Current version
1.2.1
Status
Stable
License
open
Accessibility reviewed
No review date recorded
Last breaking change
No date recorded
Deprecation
Not deprecated
Contract
v6
Foundation
≥ 1.0.0