Skip to content
Brok UI

Loading…

No results

Chart Blocks

Open source

Chart compositions on the chart-card shell: a KPI metric with a headline figure, a dual-axis column/line combo, a waterfall bridge and a grid of liquid gauges. One chart in a card is chart-card plus a chart example. Comparison instead frames a two-series bar chart in a tray, with a range select swapping the bundled dataset client-side.

Preview

3 of 5

resources/views/blocks/chart-waterfall.blade.php Blade
@props([
    'heading' => 'Cash flow bridge',
    'subheading' => 'This quarter ($k)',
    'trend' => '+40k',
    'steps' => null,
    'height' => 320,
])

@php
    // Each step carries a delta; a null delta marks a total bar, which spans
    // from zero up to the running cumulative. Colours are left to the wrapper
    // palette so the bridge stays on-token.
    $steps ??= [
        ['label' => __('Start'), 'delta' => 100],
        ['label' => __('Sales'), 'delta' => 48],
        ['label' => __('Refunds'), 'delta' => -12],
        ['label' => __('Services'), 'delta' => 30],
        ['label' => __('Costs'), 'delta' => -26],
        ['label' => __('Net'), 'delta' => null],
    ];

    // Turning deltas into floating range bars is what this block is for: the
    // consumer hands over a running list of changes, not pre-bridged pairs.
    $cumulative = 0;
    $bars = [];

    foreach ($steps as $step) {
        $label = $step['label'] ?? '';
        $delta = $step['delta'] ?? null;

        if ($delta === null) {
            $bars[] = ['x' => $label, 'y' => [0, $cumulative]];

            continue;
        }

        $from = $cumulative;
        $cumulative += $delta;
        $bars[] = ['x' => $label, 'y' => [$from, $cumulative]];
    }

    $options = [
        'plotOptions' => ['bar' => ['borderRadius' => 2]],
        'dataLabels' => ['enabled' => false],
        'legend' => ['show' => false],
    ];
@endphp

<x-ui.chart-card
    :heading="$heading"
    :subheading="$subheading"
    :trend="$trend"
    {{ $attributes }}
>
    <x-ui.chart
        type="rangeBar"
        :series="[['data' => $bars]]"
        :options="$options"
        :height="$height"
        :label="__($heading)"
    />
</x-ui.chart-card>

Installation

terminal
php artisan ui:add blocks/chart-waterfall

Installs these dependencies automatically:

Registry contract

Install confidence

php artisan ui:add blocks/chart-waterfall 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.1
License
open
Stability
stable
Contract
v1
Foundation
≥ 1.0.0
Type Generated target
blade resources/views/blocks/chart-waterfall.blade.php

Registry dependencies

chart-card chart

Package dependencies

composer: jml/brok:^0.2

npm: apexcharts

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.

chart-waterfall.md
# Brok UI block: Chart Waterfall (`chart-waterfall`)

A chart card bridging a running total across rising and falling steps to a net figure, turning a list of deltas into floating range 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/chart-waterfall
```

## Render it

```blade
<x-blocks.chart-waterfall />
```

## Props

- `heading` (string, default `Cash flow bridge`) — Card title.
- `subheading` (string, default `This quarter ($k)`) — Supporting description.
- `trend` (string|null, default `+40k`) — Delta badge.
- `steps` (array|null, default `null`) — Rows of {label, delta}; a null delta marks a total bar spanning zero to the running cumulative.
- `height` (int, default `320`) — Chart height in pixels.

## Use when

- A total has to be explained as a sequence of gains and losses.
- A cash-flow, budget-variance or headcount bridge is shown from opening to closing balance.

## Avoid when

- The steps do not accumulate; a bar chart is clearer.
- The parts are shares of one whole; use a pie or treemap.

## Rules

- Render the installed block with `<x-blocks.chart-waterfall />` 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/chart-waterfall
- Registry JSON (files, props, contract): https://brokui.dev/r/open/blocks/chart-waterfall.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

  • A total has to be explained as a sequence of gains and losses.
  • A cash-flow, budget-variance or headcount bridge is shown from opening to closing balance.

Avoid when

  • The steps do not accumulate; a bar chart is clearer.
  • The parts are shares of one whole; use a pie or treemap.

Anti-patterns

  • Do not replace semantic props with conflicting utility classes.
  • Do not remove labels, focus styles, or state attributes.
Anatomy
chart card trend badge floating range bars total bar

Usage

Render the block as a component, passing data where useful:

resources/views/welcome.blade.php Blade
<x-blocks.chart-waterfall />

Built from primitives

Composes <brok:*> Semantic tokens Re-themeable RTL-ready

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.

resources/views/blocks/chart-waterfall.blade.php Blade
@props([
    'heading' => 'Cash flow bridge',
    'subheading' => 'This quarter ($k)',
    'trend' => '+40k',
    'steps' => null,
    'height' => 320,
])

@php
    // Each step carries a delta; a null delta marks a total bar, which spans
    // from zero up to the running cumulative. Colours are left to the wrapper
    // palette so the bridge stays on-token.
    $steps ??= [
        ['label' => __('Start'), 'delta' => 100],
        ['label' => __('Sales'), 'delta' => 48],
        ['label' => __('Refunds'), 'delta' => -12],
        ['label' => __('Services'), 'delta' => 30],
        ['label' => __('Costs'), 'delta' => -26],
        ['label' => __('Net'), 'delta' => null],
    ];

    // Turning deltas into floating range bars is what this block is for: the
    // consumer hands over a running list of changes, not pre-bridged pairs.
    $cumulative = 0;
    $bars = [];

    foreach ($steps as $step) {
        $label = $step['label'] ?? '';
        $delta = $step['delta'] ?? null;

        if ($delta === null) {
            $bars[] = ['x' => $label, 'y' => [0, $cumulative]];

            continue;
        }

        $from = $cumulative;
        $cumulative += $delta;
        $bars[] = ['x' => $label, 'y' => [$from, $cumulative]];
    }

    $options = [
        'plotOptions' => ['bar' => ['borderRadius' => 2]],
        'dataLabels' => ['enabled' => false],
        'legend' => ['show' => false],
    ];
@endphp

<x-ui.chart-card
    :heading="$heading"
    :subheading="$subheading"
    :trend="$trend"
    {{ $attributes }}
>
    <x-ui.chart
        type="rangeBar"
        :series="[['data' => $bars]]"
        :options="$options"
        :height="$height"
        :label="__($heading)"
    />
</x-ui.chart-card>

Ownership & lifecycle

Owner, release state, review evidence and adoption for this item.
Owner
Platform UI (@JoshJML)
Current version
1.0.1
Status
Stable
License
open
Deprecation
Not deprecated
Contract
v1
Foundation
≥ 1.0.0