Metrics
Dashboard analytics cards — a traffic trend card with a range control, a KPI performance row with sparklines, a sales-by-channel distribution, a weekly-traffic heatmap and a spending breakdown with a segmented bar and table.
Preview
@props([
'heading' => null,
'subheading' => null,
'metrics' => null,
])
@php
$heading ??= __('Financial Performance');
$subheading ??= __('Real-time insights for the last 30 days');
$metrics ??= [
['label' => __('Revenue'), 'value' => '$12,345', 'delta' => '+7.2%', 'tone' => 'success', 'data' => [8, 9, 7, 11, 10, 13, 12, 15]],
['label' => __('Avg. Order'), 'value' => '$248', 'delta' => '+3.1%', 'tone' => 'primary', 'data' => [5, 6, 6, 7, 6, 8, 7, 9]],
['label' => __('Conversion'), 'value' => '7.2%', 'delta' => '-0.8%', 'tone' => 'destructive', 'data' => [9, 8, 8, 7, 7, 6, 7, 6]],
];
@endphp
<x-ui.card {{ $attributes->merge(['class' => 'w-full']) }}>
<x-ui.card.header class="flex flex-row items-start justify-between gap-4">
<div class="flex flex-col gap-2">
<x-ui.card.title>{{ $heading }}</x-ui.card.title>
<x-ui.card.description>{{ $subheading }}</x-ui.card.description>
</div>
<x-ui.button variant="ghost" size="icon" class="-me-2 shrink-0">
<svg viewBox="0 0 24 24" fill="currentColor" class="size-5" aria-hidden="true">
<circle cx="12" cy="5" r="1.75" />
<circle cx="12" cy="12" r="1.75" />
<circle cx="12" cy="19" r="1.75" />
</svg>
<span class="sr-only">{{ __('Open menu') }}</span>
</x-ui.button>
</x-ui.card.header>
<x-ui.card.content>
<div class="grid grid-cols-1 gap-4 sm:grid-cols-3">
@foreach ($metrics as $m)
<div>
<x-ui.stat :label="$m['label']" :value="$m['value']" :delta="$m['delta']" />
<x-ui.sparkline
:data="$m['data']"
variant="area"
:tone="$m['tone']"
:show-baseline="true"
class="mt-4 h-9 w-full"
/>
</div>
@endforeach
</div>
</x-ui.card.content>
</x-ui.card>
Installation
php artisan ui:add blocks/metrics-kpis
Registry contract
Install confidence
php artisan ui:add blocks/metrics-kpis
writes only the generated targets below. The CLI validates each file hash before writing and
prompts before replacing local changes unless --force is used.
- Version
- 1.0.3
- License
- open
- Stability
- stable
- Contract
- v1
- Foundation
- ≥ 1.0.0
| Type | Generated target |
|---|---|
| blade | resources/views/blocks/metrics-kpis.blade.php |
Registry dependencies
Package dependencies
composer: jml/brok:^0.2
Use with AI
A brief for your coding agent: what the block is, the install command, how to render it, its props and the rules. Copy it, or open a prompt about this block in an assistant.
# Brok UI block: Metric Revenue (`metrics-kpis`)
A financial-performance KPI card showing revenue, average order value and conversion as stat cells with deltas and inline sparklines, plus a header actions menu.
Brok UI is a Laravel Blade registry. `ui:add` copies this block into the app as plain Blade the app owns; it composes installed `<brok:*>` primitives and semantic design tokens.
## Install
```bash
php artisan ui:add blocks/metrics-kpis
```
## Render it
```blade
<x-blocks.metrics-kpis />
```
## Props
- `heading` (mixed|null, default `null`) — Card title; null defaults to "Financial Performance".
- `subheading` (mixed|null, default `null`) — Supporting copy under the heading; null defaults to a 30-day sample caption.
- `metrics` (mixed|null, default `null`) — Rows of {label, value, delta, tone, data}; null falls back to a 3-item revenue/AOV/conversion sample.
## Use when
- Showing several KPIs, such as revenue, average order value, and conversion, as stat cells each paired with an inline sparkline.
- Summarising financial performance in a compact grid within a single card.
## Avoid when
- Needing one metric plotted as a full time-series chart instead of several stat cells; use metrics-traffic.
## Rules
- Render the installed block with `<x-blocks.metrics-kpis />` and pass data through its props; edit the copied file only for structural changes.
- Keep the semantic design tokens (`bg-background`, `text-muted-foreground`); never swap in raw colour utilities.
- Keep the `data-slot` attributes and the logical (start/end) spacing so the markup still mirrors under `dir="rtl"`.
## Links
- Docs: https://brokui.dev/blocks/metrics-kpis
- Registry JSON (files, props, contract): https://brokui.dev/r/open/blocks/metrics-kpis.json
Working in Claude Code, Cursor or Codex? Give the agent the whole registry through the MCP server or the Brok UI skill.
Guidance
Use when
- Showing several KPIs, such as revenue, average order value, and conversion, as stat cells each paired with an inline sparkline.
- Summarising financial performance in a compact grid within a single card.
Avoid when
- Needing one metric plotted as a full time-series chart instead of several stat cells; use metrics-traffic.
Anti-patterns
- Do not replace semantic props with conflicting utility classes.
- Do not remove labels, focus styles, or state attributes.
- Anatomy
Usage
Render the block as a component, passing data where useful:
<x-blocks.metrics-kpis />
Built from primitives
This block composes installed <brok:*> primitives and semantic design
tokens only — it does not reimplement any primitive. Re-theme it (light, dark, admin, customer) by
editing CSS variables; flip the preview to RTL to confirm it mirrors.
Source
The exact, editable file ui:add writes
into your app. The preview above renders this same source — there are no preview-only blocks.
@props([
'heading' => null,
'subheading' => null,
'metrics' => null,
])
@php
$heading ??= __('Financial Performance');
$subheading ??= __('Real-time insights for the last 30 days');
$metrics ??= [
['label' => __('Revenue'), 'value' => '$12,345', 'delta' => '+7.2%', 'tone' => 'success', 'data' => [8, 9, 7, 11, 10, 13, 12, 15]],
['label' => __('Avg. Order'), 'value' => '$248', 'delta' => '+3.1%', 'tone' => 'primary', 'data' => [5, 6, 6, 7, 6, 8, 7, 9]],
['label' => __('Conversion'), 'value' => '7.2%', 'delta' => '-0.8%', 'tone' => 'destructive', 'data' => [9, 8, 8, 7, 7, 6, 7, 6]],
];
@endphp
<x-ui.card {{ $attributes->merge(['class' => 'w-full']) }}>
<x-ui.card.header class="flex flex-row items-start justify-between gap-4">
<div class="flex flex-col gap-2">
<x-ui.card.title>{{ $heading }}</x-ui.card.title>
<x-ui.card.description>{{ $subheading }}</x-ui.card.description>
</div>
<x-ui.button variant="ghost" size="icon" class="-me-2 shrink-0">
<svg viewBox="0 0 24 24" fill="currentColor" class="size-5" aria-hidden="true">
<circle cx="12" cy="5" r="1.75" />
<circle cx="12" cy="12" r="1.75" />
<circle cx="12" cy="19" r="1.75" />
</svg>
<span class="sr-only">{{ __('Open menu') }}</span>
</x-ui.button>
</x-ui.card.header>
<x-ui.card.content>
<div class="grid grid-cols-1 gap-4 sm:grid-cols-3">
@foreach ($metrics as $m)
<div>
<x-ui.stat :label="$m['label']" :value="$m['value']" :delta="$m['delta']" />
<x-ui.sparkline
:data="$m['data']"
variant="area"
:tone="$m['tone']"
:show-baseline="true"
class="mt-4 h-9 w-full"
/>
</div>
@endforeach
</div>
</x-ui.card.content>
</x-ui.card>
Ownership & lifecycle
Owner, release state, review evidence and adoption for this item.
- Owner
- Platform UI (@JoshJML)
- Current version
-
1.0.3 - Status
- Stable
- License
-
open - Deprecation
- Not deprecated
- Contract
-
v1 - Foundation
-
≥ 1.0.0