Block Bar
Unicode block-character bar for displaying proportional values. Supports single-value and multi-segment stacked bars.
Installation
dgadd ships in @diffgazer/add on npm: pnpm add -D @diffgazer/add puts it on pnpm exec, and npx @diffgazer/add runs it without the install.
UI components require Tailwind CSS v4. Local copy mode imports src/styles/styles.css; package mode uses @diffgazer/ui CSS from the installed package.
Usage
Examples
Stats
Multi-Segment
API Reference
BlockBar
BlockBar.Segment
Accessibility
Notes
Simple Mode
Single-value bar: <BlockBar label="Errors" value={3} max={45} variant="error" />. Label, bar, and value display are rendered automatically.
Multi-Segment Mode
Pass a segments array: segments={[{ value: 60, variant: 'success' }, { value: 25, variant: 'warning' }]}. Value is derived from the segment sum unless explicitly provided. Cells are allocated across ordered segments, so an exact max-total fills the configured width without clipping later segments. When segments and children are both provided, segments win and define rendering and value. Each segment also accepts className for app-owned colors the built-in variants do not cover.
Compound Mode
Pass BlockBar.Segment children for custom per-segment content (labels, event handlers, tooltips). Cells are allocated across the segment children in order. Root renders the empty background automatically.
Value Text
Set valueText to customize aria-valuetext for app-owned labels such as severity summaries. The visible value remains numeric.
Color Variants
The variant prop accepts: default, muted, error, warning, success, info.
Custom Characters
filledChar (default: █) and emptyChar (default: ░) control the block characters. Individual segments can override with the char prop.
Source
Install via CLI: pnpm exec dgadd add ui/block-bar.
Highlighted source loads after this disclosure opens. Browse the source repository.