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' => 'Sales by Channel',
'subheading' => 'Distribution of sales across acquisition channels',
'channels' => null,
])
@php
$channels ??= [
['name' => __('Direct'), 'value' => 5200, 'tone' => 'primary'],
['name' => __('Social'), 'value' => 3800, 'tone' => 'info'],
['name' => __('Organic'), 'value' => 2500, 'tone' => 'success'],
];
$total = array_sum(array_column($channels, 'value'));
@endphp
<x-ui.card {{ $attributes->merge(['class' => 'w-full']) }}>
<x-ui.card.header>
<div class="flex 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.badge variant="secondary" class="tabular-nums">{{ number_format($total) }}</x-ui.badge>
</div>
</x-ui.card.header>
<x-ui.card.content>
<div class="space-y-6">
@foreach ($channels as $c)
<div>
<dl class="mb-2 flex items-center justify-between gap-4">
<dt class="text-sm font-medium text-foreground">{{ $c['name'] }}</dt>
<dd class="flex items-baseline gap-2 text-sm">
<span class="font-semibold tabular-nums text-foreground">{{ number_format($c['value']) }}</span>
<span class="tabular-nums text-muted-foreground">{{ $total > 0 ? round($c['value'] / $total * 100) : 0 }}%</span>
</dd>
</dl>
<x-ui.progress :value="$c['value']" :max="$total" :tone="$c['tone'] ?? 'default'" class="h-2" />
</div>
@endforeach
</div>
</x-ui.card.content>
</x-ui.card>
Installation
php artisan ui:add blocks/metrics-channels
Registry contract
Install confidence
php artisan ui:add blocks/metrics-channels
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.4
- License
- open
- Stability
- stable
- Contract
- v1
- Foundation
- ≥ 1.0.0
| Type | Generated target |
|---|---|
| blade | resources/views/blocks/metrics-channels.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 Channels (`metrics-channels`)
A sales-by-channel distribution card listing acquisition channels with values, share percentages and token-themed horizontal bars.
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-channels
```
## Render it
```blade
<x-blocks.metrics-channels />
```
## Props
- `heading` (string, default `Sales by Channel`) — Card title.
- `subheading` (string, default `Distribution of sales across acquisition channels`) — Supporting copy under the heading.
- `channels` (mixed|null, default `null`) — Rows of {name, value, tone}; null falls back to a 3-channel sample: Direct, Social, Organic.
## Use when
- Breaking down sales or traffic by acquisition channel as a labelled list with value, share percentage, and a horizontal bar per channel.
- Summing channel totals into a badge in the header.
## Avoid when
- Needing a time-series trend or KPI cells with sparklines instead of a channel-share breakdown; use metrics-traffic or metrics-kpis.
## Rules
- Render the installed block with `<x-blocks.metrics-channels />` 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-channels
- Registry JSON (files, props, contract): https://brokui.dev/r/open/blocks/metrics-channels.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
- Breaking down sales or traffic by acquisition channel as a labelled list with value, share percentage, and a horizontal bar per channel.
- Summing channel totals into a badge in the header.
Avoid when
- Needing a time-series trend or KPI cells with sparklines instead of a channel-share breakdown; use metrics-traffic or metrics-kpis.
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-channels />
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' => 'Sales by Channel',
'subheading' => 'Distribution of sales across acquisition channels',
'channels' => null,
])
@php
$channels ??= [
['name' => __('Direct'), 'value' => 5200, 'tone' => 'primary'],
['name' => __('Social'), 'value' => 3800, 'tone' => 'info'],
['name' => __('Organic'), 'value' => 2500, 'tone' => 'success'],
];
$total = array_sum(array_column($channels, 'value'));
@endphp
<x-ui.card {{ $attributes->merge(['class' => 'w-full']) }}>
<x-ui.card.header>
<div class="flex 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.badge variant="secondary" class="tabular-nums">{{ number_format($total) }}</x-ui.badge>
</div>
</x-ui.card.header>
<x-ui.card.content>
<div class="space-y-6">
@foreach ($channels as $c)
<div>
<dl class="mb-2 flex items-center justify-between gap-4">
<dt class="text-sm font-medium text-foreground">{{ $c['name'] }}</dt>
<dd class="flex items-baseline gap-2 text-sm">
<span class="font-semibold tabular-nums text-foreground">{{ number_format($c['value']) }}</span>
<span class="tabular-nums text-muted-foreground">{{ $total > 0 ? round($c['value'] / $total * 100) : 0 }}%</span>
</dd>
</dl>
<x-ui.progress :value="$c['value']" :max="$total" :tone="$c['tone'] ?? 'default'" class="h-2" />
</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.4 - Status
- Stable
- License
-
open - Deprecation
- Not deprecated
- Contract
-
v1 - Foundation
-
≥ 1.0.0