Skip to main content
brickwork
GitHub Log in Get started
Display
Theme
Density
Direction
Brand

Documentation

Stat comparison

A compact before-and-after metric comparison.

All components Component Brickwork 4.3.1

Try it

Month comparison

Open full-page preview

Current versus previous period.

Orders 128 112
Use where two values need a direct visual comparison.

Use it

Working invocation

This code creates the configuration shown above. Copy the template and the required Python context together.

templates/your_app/component.html

Django template

{% include "brickwork/components/_stat_comparison.html" with label=label current=current previous=previous %}

your_app/views.py

Python

context = {'label': 'Orders', 'current': '128', 'previous': '112'}

Guide

Add it to your project

  1. Include with formatted values and labels.

View this component's source for the installed release

Options

Public API

Option Type Default Required Description
current string Not set Yes Current formatted value. Constraint: Must match an identifier declared by the corresponding structured collection.
previous string Not set Yes Previous formatted value. Constraint: No additional package-level validation is documented beyond this option's stated type and its role in the component.
label string Not set No Metric name. Constraint: Use concise visible text that identifies the control or measurement.
period_label string Not set No Visible comparison caption. Constraint: No additional package-level validation is documented beyond this option's stated type and its role in the component.
trend string Not set No Caller-supplied direction. Allowed: up, down, flat. Constraint: Allowed values: `up`, `down`, `flat`.
trend_label string Not set No Visible delta. Constraint: No additional package-level validation is documented beyond this option's stated type and its role in the component.
sentiment string Not set No Optional judgement colour. Allowed: good, bad. Constraint: Allowed values: `good`, `bad`.
size string md No Comparison tile scale. Allowed: sm, md, lg. Constraint: Use one of the documented size choices; unsupported values are not a responsive substitute.

Behaviour

Accessibility and responsive behaviour

Accessibility
Visible labels and values carry the comparison.
Responsive
No breakpoint-specific contract.
Without JavaScript
Static comparison.

Need help?

Troubleshooting

Contract check: (tabular numerals, VIZ-020: brickwork never formats or computes this).

Provide already formatted current and previous values plus an explicit trend; Brickwork does not infer comparison arithmetic from display strings.

Documentation