VibeUI
ComponentsDocs
VibeUI

Components with taste, that you own. Copy the source, retint the tokens, keep every line.

Library

  • All components
  • Signature pieces
  • Text effects
  • Footers

Docs

  • Introduction
  • Installation
  • Theming
  • CLI

Project

  • GitHub
  • Agents and MCP
  • Issues
  • MIT license
© 2026 VibeUI · MIT licensed
  1. Components
  2. Data & surfaces
  3. Comparison

Comparison

Two-sided proportion bar for comparing a pair of values.

Data & surfacesServer-safe
Light 42%58% Dark
Mobile 71%29% Desktop

Install

bash
npx @agents-npm-packages/vibeui add comparison --dir ./src/components/ui

Import

tsx
import { ComparisonBar } from "@/components/ui/comparison"

API

Generated from the component's TypeScript types, so it always matches the source. * marks a required prop.

<ComparisonBar>

PropTypeDefaultDescription
left*string—Content (or label) for the left side.
right*string—Content (or label) for the right side.
leftValue*number—Magnitude of the left side.
rightValue*number—Magnitude of the right side.
classNamestring—Extra classes, merged with the component's own.

Source

src/components/ui/comparison.tsx
import { cn } from "@/lib/utils";

/** Two-sided proportion bar for comparing a pair of values. */
export function ComparisonBar({
  left,
  right,
  leftValue,
  rightValue,
  className,
}: {
  left: string;
  right: string;
  leftValue: number;
  rightValue: number;
  className?: string;
}) {
  const total = leftValue + rightValue || 1;
  const leftPct = (leftValue / total) * 100;

  return (
    <div className={cn("w-full", className)}>
      <div className="mb-2.5 flex justify-between text-[13px]">
        <span className="font-medium text-ink">
          {left}{" "}
          <span className="ml-1 font-mono text-xs text-muted">
            {Math.round(leftPct)}%
          </span>
        </span>
        <span className="font-medium text-ink">
          <span className="mr-1 font-mono text-xs text-muted">
            {Math.round(100 - leftPct)}%
          </span>{" "}
          {right}
        </span>
      </div>
      <div className="flex h-2.5 gap-1">
        <div
          className="h-full rounded-full bg-accent transition-[width] duration-700 ease-out"
          style={{ width: `${leftPct}%` }}
        />
        <div
          className="h-full flex-1 rounded-full bg-surface-sunken ring-1 ring-inset ring-line-strong"
        />
      </div>
    </div>
  );
}

Exports ComparisonBar. Peer dependencies: clsx, tailwind-merge.

PreviousColor SwatchNextDonut Chart