Before and after figures
The same four measures twice, with the change carried by arrow, sign and colour.
Marketingstarterstatsbefore-afterdeltamigration
Live preview
full widthLive preview — open it in a new tab for the full-height version.
Source
This exact file renders the preview above.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import { ArrowDownRight, ArrowUpRight } from 'lucide-react'
import { Container } from '@/components/ui/layout'
/**
* Before / after statistics pair
*
* The same four measures, twice. Direction is carried by an arrow, a sign and
* a colour, so the improvement is legible in greyscale — which matters,
* because this section is the one people screenshot.
*/
const rows = [
{
label: 'JavaScript shipped',
before: '64 kB',
after: '14 kB',
delta: -78,
better: 'down' as const,
},
{
label: 'Largest contentful paint',
before: '1.5 s',
after: '0.9 s',
delta: -41,
better: 'down' as const,
},
{
label: 'Components maintained',
before: '4 sets',
after: '1 set',
delta: -75,
better: 'down' as const,
},
{
label: 'Time to a new screen',
before: '5 days',
after: '2 days',
delta: -60,
better: 'down' as const,
},
]
export default function ComparisonPairStats() {
return (
<section className="border-b border-line bg-surface-sunken py-section">
<Container>
<div className="max-w-2xl">
<h2 className="display-type text-2xl font-semibold text-ink-strong sm:text-3xl">
Northwind, before and after consolidation.
</h2>
<p className="mt-3 text-md text-ink-muted">
A fictional client, measured across one quarter of migration work.
</p>
</div>
<div className="mt-10 overflow-hidden rounded-xl border border-line bg-surface">
<div className="grid grid-cols-[1fr_auto_auto_auto] gap-x-4 border-b border-line bg-surface-sunken px-5 py-3 sm:gap-x-8">
<span className="label-caps text-ink-subtle">Measure</span>
<span className="label-caps text-right text-ink-subtle">Before</span>
<span className="label-caps text-right text-ink-subtle">After</span>
<span className="label-caps text-right text-ink-subtle">Change</span>
</div>
<ul>
{rows.map((row) => {
const good = row.better === 'down' ? row.delta < 0 : row.delta > 0
const Icon = row.delta < 0 ? ArrowDownRight : ArrowUpRight
return (
<li
key={row.label}
className="grid grid-cols-[1fr_auto_auto_auto] items-baseline gap-x-4 border-b border-line-subtle px-5 py-3.5 last:border-0 sm:gap-x-8"
>
<span className="text-sm text-ink">{row.label}</span>
<span className="text-right font-mono text-sm text-ink-subtle tabular-nums line-through">
{row.before}
</span>
<span className="text-right font-mono text-sm font-semibold text-ink-strong tabular-nums">
{row.after}
</span>
<span
className={`flex items-center justify-end gap-0.5 text-right font-mono text-sm tabular-nums ${
good ? 'text-success' : 'text-danger'
}`}
>
<Icon className="size-3.5" aria-hidden="true" />
{row.delta > 0 ? '+' : ''}
{row.delta}%
</span>
</li>
)
})}
</ul>
</div>
</Container>
</section>
)
}
components/blocks/sections/stats/comparison-pair.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import { ArrowDownRight, ArrowUpRight } from 'lucide-react'
import { Container } from '@/components/ui/layout'
/**
* Before / after statistics pair
*
* The same four measures, twice. Direction is carried by an arrow, a sign and
* a colour, so the improvement is legible in greyscale — which matters,
* because this section is the one people screenshot.
*/
const rows = [
{
label: 'JavaScript shipped',
before: '64 kB',
after: '14 kB',
delta: -78,
better: 'down' as const,
},
{
label: 'Largest contentful paint',
before: '1.5 s',
after: '0.9 s',
delta: -41,
better: 'down' as const,
},
{
label: 'Components maintained',
before: '4 sets',
after: '1 set',
delta: -75,
better: 'down' as const,
},
{
label: 'Time to a new screen',
before: '5 days',
after: '2 days',
delta: -60,
better: 'down' as const,
},
]
export default function ComparisonPairStats() {
return (
<section className="border-b border-line bg-surface-sunken py-section">
<Container>
<div className="max-w-2xl">
<h2 className="display-type text-2xl font-semibold text-ink-strong sm:text-3xl">
Northwind, before and after consolidation.
</h2>
<p className="mt-3 text-md text-ink-muted">
A fictional client, measured across one quarter of migration work.
</p>
</div>
<div className="mt-10 overflow-hidden rounded-xl border border-line bg-surface">
<div className="grid grid-cols-[1fr_auto_auto_auto] gap-x-4 border-b border-line bg-surface-sunken px-5 py-3 sm:gap-x-8">
<span className="label-caps text-ink-subtle">Measure</span>
<span className="label-caps text-right text-ink-subtle">Before</span>
<span className="label-caps text-right text-ink-subtle">After</span>
<span className="label-caps text-right text-ink-subtle">Change</span>
</div>
<ul>
{rows.map((row) => {
const good = row.better === 'down' ? row.delta < 0 : row.delta > 0
const Icon = row.delta < 0 ? ArrowDownRight : ArrowUpRight
return (
<li
key={row.label}
className="grid grid-cols-[1fr_auto_auto_auto] items-baseline gap-x-4 border-b border-line-subtle px-5 py-3.5 last:border-0 sm:gap-x-8"
>
<span className="text-sm text-ink">{row.label}</span>
<span className="text-right font-mono text-sm text-ink-subtle tabular-nums line-through">
{row.before}
</span>
<span className="text-right font-mono text-sm font-semibold text-ink-strong tabular-nums">
{row.after}
</span>
<span
className={`flex items-center justify-end gap-0.5 text-right font-mono text-sm tabular-nums ${
good ? 'text-success' : 'text-danger'
}`}
>
<Icon className="size-3.5" aria-hidden="true" />
{row.delta > 0 ? '+' : ''}
{row.delta}%
</span>
</li>
)
})}
</ul>
</div>
</Container>
</section>
)
}
components/ui/layout.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
import type { ElementType, HTMLAttributes, ReactNode } from 'react'
import { cn } from '@/lib/cn'
/**
* Layout primitives
*
* Five zero-JavaScript building blocks that account for the majority of
* structure in the library. They exist so that spacing decisions are made once,
* against density tokens, instead of being re-typed as ad-hoc utilities in
* every section.
*/
export interface ContainerProps extends HTMLAttributes<HTMLDivElement> {
/** `prose` narrows to a comfortable reading measure. */
size?: 'prose' | 'narrow' | 'default' | 'wide' | 'full'
as?: ElementType
/** Removes the responsive horizontal gutter. */
bleed?: boolean
}
const containerSizes = {
prose: 'max-w-[var(--layout-prose-max)]',
narrow: 'max-w-3xl',
default: 'max-w-[var(--layout-content-max)]',
wide: 'max-w-[110rem]',
full: 'max-w-none',
} as const
export function Container({
size = 'default',
as: Tag = 'div',
bleed = false,
className,
children,
...props
}: ContainerProps) {
return (
<Tag
className={cn(
'mx-auto w-full',
containerSizes[size],
!bleed && 'px-4 sm:px-6 lg:px-8',
className,
)}
{...props}
>
{children}
</Tag>
)
}
export interface StackProps extends HTMLAttributes<HTMLDivElement> {
direction?: 'row' | 'column'
gap?: 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl'
align?: 'start' | 'center' | 'end' | 'stretch' | 'baseline'
justify?: 'start' | 'center' | 'end' | 'between' | 'around'
wrap?: boolean
as?: ElementType
}
const gapMap = {
none: 'gap-0',
xs: 'gap-1',
sm: 'gap-2',
md: 'gap-gap',
lg: 'gap-stack',
xl: 'gap-8',
} as const
const alignMap = {
start: 'items-start',
center: 'items-center',
end: 'items-end',
stretch: 'items-stretch',
baseline: 'items-baseline',
} as const
const justifyMap = {
start: 'justify-start',
center: 'justify-center',
end: 'justify-end',
between: 'justify-between',
around: 'justify-around',
} as const
export function Stack({
direction = 'column',
gap = 'md',
align,
justify,
wrap = false,
as: Tag = 'div',
className,
children,
...props
}: StackProps) {
return (
<Tag
className={cn(
'flex',
direction === 'column' ? 'flex-col' : 'flex-row',
gapMap[gap],
align && alignMap[align],
justify && justifyMap[justify],
wrap && 'flex-wrap',
className,
)}
{...props}
>
{children}
</Tag>
)
}
export interface GridProps extends HTMLAttributes<HTMLDivElement> {
/** Column count at the largest breakpoint; smaller breakpoints step down. */
cols?: 1 | 2 | 3 | 4 | 5 | 6
gap?: StackProps['gap']
as?: ElementType
/** Auto-fit tracks with a minimum width instead of a fixed column count. */
minItemWidth?: string
}
const colMap = {
1: 'grid-cols-1',
2: 'grid-cols-1 sm:grid-cols-2',
3: 'grid-cols-1 sm:grid-cols-2 lg:grid-cols-3',
4: 'grid-cols-1 sm:grid-cols-2 lg:grid-cols-4',
5: 'grid-cols-2 sm:grid-cols-3 lg:grid-cols-5',
6: 'grid-cols-2 sm:grid-cols-3 lg:grid-cols-6',
} as const
export function Grid({
cols = 3,
gap = 'lg',
as: Tag = 'div',
minItemWidth,
className,
style,
children,
...props
}: GridProps) {
return (
<Tag
className={cn('grid', minItemWidth ? undefined : colMap[cols], gapMap[gap], className)}
style={
minItemWidth
? {
...style,
gridTemplateColumns: `repeat(auto-fit, minmax(min(${minItemWidth}, 100%), 1fr))`,
}
: style
}
{...props}
>
{children}
</Tag>
)
}
export interface DividerProps extends HTMLAttributes<HTMLDivElement> {
orientation?: 'horizontal' | 'vertical'
/** Renders a centred text label interrupting the rule. */
label?: ReactNode
weight?: 'subtle' | 'default' | 'strong'
}
const dividerWeight = {
subtle: 'border-line-subtle',
default: 'border-line',
strong: 'border-line-strong',
} as const
export function Divider({
orientation = 'horizontal',
label,
weight = 'default',
className,
...props
}: DividerProps) {
if (orientation === 'vertical') {
return (
<div
role="separator"
aria-orientation="vertical"
className={cn('h-full w-px self-stretch border-l', dividerWeight[weight], className)}
{...props}
/>
)
}
if (label) {
return (
<div className={cn('flex items-center gap-3', className)} {...props}>
<span className={cn('h-px flex-1 border-t', dividerWeight[weight])} role="separator" />
<span className="label-caps text-ink-subtle">{label}</span>
<span className={cn('h-px flex-1 border-t', dividerWeight[weight])} aria-hidden="true" />
</div>
)
}
return (
<div
role="separator"
className={cn('w-full border-t', dividerWeight[weight], className)}
{...props}
/>
)
}
Demo source — adapt to your project. Foundry is not published as a package.
Usage
Direction is legible in greyscale, which matters because this is the section people screenshot.
- State the period the comparison covers, or the improvement is unfalsifiable.
- Strike through the before value rather than colouring it — colour alone is not a signal.
Variants and states
Every entry below is a genuine difference in behaviour or layout, and every one of them is visible in the preview above.
- Four-column row grid
- Struck-through before values
- Signed deltas
Accessibility
- Triple encoding
- Every change carries an arrow, a sign and a colour.
- Column headers
- Before, After and Change are labelled, not implied by position.
Foundry implements published ARIA patterns and is tested against them. No WCAG certification is claimed — see the accessibility documentation for what is and is not covered.