Components · Data Display
Comparison Bar
AlphaAdded v10.7.0
Two values on one split bar, with the numbers always shown as text.
import { ComparisonBar } from '@nexub/react';Playground
Props
size
highlight
<ComparisonBar left={{ label: 'Team A', value: 3 }} right={{ label: 'Team B', value: 1 }} label="Goals" />Examples
Default
A group of comparisons
States
defaultsize="sm"size="md"
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| labelrequired | string | — | What is compared. |
| leftrequired | ComparisonBarSide | — | The side at the inline start. |
| rightrequired | ComparisonBarSide | — | The side at the inline end. |
| valueFormat | ((value: number) => string) | String | Formats both values, on screen and in the text alternative. |
| size | 'sm' | 'md' | 'md' | Bar height and type size. |
| showValues | boolean | true | The two values and the label above the bar. |
| showLabels | boolean | true | The two side labels under the bar. Turn off for all but one bar in a group. |
| highlight | 'none' | 'higher' | 'higher' | The larger side takes the accent and the other is muted. A side with a color keeps it. |
| aria-label | string | — | Replaces the text alternative built from the props. |
On iOS & Android: ComparisonBar
@nexub/react-nativeAlpha
import { ComparisonBar } from '@nexub/react-native';
<ComparisonBar label="Orders" left={{ label: 'This week', value: 128 }} right={{ label: 'Last week', value: 96 }} />Web vs mobile
Same tokens and prop names. Where the platforms differ:
| Web | iOS & Android | |
|---|---|---|
| Text alternative | The bar is an image; aria-label replaces its name. | The whole component is one image; accessibilityLabel replaces its name. |
| Motion | The split moves with a CSS transition. | The split glides on the spatial spring (Reanimated); Reduce Motion is honoured. |
Interactive preview of @nexub/react-native rendered for the web. Native chrome (switches, pickers, Liquid Glass) looks like the platform on a device.
On device

iPhone (iOS simulator)

Pixel (Android emulator)
Screenshots from the latest CI run of the showcase app; the live frame renders the same code for the web.
ComparisonBar props
| Prop | Type | Default | Description |
|---|---|---|---|
| labelrequired | string | — | What is compared, e.g. "Orders". |
| leftrequired | ComparisonBarSide | — | The side at the inline start (the left in left-to-right text). |
| rightrequired | ComparisonBarSide | — | The side at the inline end. |
| valueFormat | (value: number) => string | String | — |
| size | 'sm' | 'md' | 'md' | — |
| showValues | boolean | true | The two values and the label above the bar. |
| showLabels | boolean | true | The two side labels under the bar. Turn off for every bar but one in a group. |
| highlight | 'higher' | 'none' | 'higher' | higher: the larger side takes the accent and the other is muted; equal values look the same. |
| accessibilityLabel | string | — | Replaces the text alternative built from the props ("Orders: Team A 3, Team B 1"). |