@molecule/app-comparison-row-svelte

Feature · comparison-row · App (browser) · v1.1.5 · Apache-2.0

Period-over-period stat comparison ("$X vs $Y", with delta)

npm install @molecule/app-comparison-row-svelte

npm · Source on GitHub

How it works

@molecule/app-comparison-row-svelte is a ready-made comparison-row feature for the app (browser) side. It composes the core interfaces it needs, so it works with whichever providers your app has bonded.

<script lang="ts">
  import { ComparisonRow } from '@molecule/app-comparison-row-svelte'
</script>

<ComparisonRow
  label="Revenue"
  current="$24,800"
  previous="$21,300"
  deltaPct={16.4}
  periodLabel="vs. last month"
/>

Works with: @molecule/app-svelte, @molecule/app-ui, @molecule/app-ui-svelte

Reference

Svelte period-over-period stat comparison row — the Svelte counterpart of @molecule/app-comparison-row-react, with the same props and the same DOM for the same input.

Exports ComparisonRow: current value, optional previous value, and a coloured delta% chip for dashboards, report summaries and finance overviews.

Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit src/index.ts JSDoc, not this file.

Quick Start

<script lang="ts">
  import { ComparisonRow } from '@molecule/app-comparison-row-svelte'
</script>

<ComparisonRow
  label="Revenue"
  current="$24,800"
  previous="$21,300"
  deltaPct={16.4}
  periodLabel="vs. last month"
/>

Type

feature

Installation

npm install @molecule/app-comparison-row-svelte @molecule/app-svelte @molecule/app-ui @molecule/app-ui-svelte svelte

API

Interfaces

ComparisonRowProps

Props accepted by the ComparisonRow component.

interface ComparisonRowProps {
  /** Label for the metric (e.g. "Revenue"). */
  label: Snippet | string
  /** Current period value (formatted). */
  current: Snippet | string
  /** Previous period value (formatted). */
  previous?: Snippet | string
  /** Numeric delta% — drives direction + color when present. */
  deltaPct?: number
  /** Custom delta formatter. */
  formatDelta?: Snippet<[number]>
  /** Optional sub-text ("vs. last week"). */
  periodLabel?: Snippet | string
  /** Extra classes. */
  className?: string
}

Constants

ComparisonRow

const ComparisonRow: LegacyComponentType

Injection Notes

Requirements

Peer dependencies:

  • @molecule/app-svelte ^3.13.0 || ^4.0.0
  • @molecule/app-ui ^1.4.0
  • @molecule/app-ui-svelte ^1.1.0
  • svelte ^5.0.0

Runtime Dependencies

  • @molecule/app-svelte
  • @molecule/app-ui
  • @molecule/app-ui-svelte
  • svelte

The delta chip colors by SIGN with fixed semantics: positive = green, negative = red (hardcoded hexes applied inline, not theme tokens). There is no "down-is-good" inversion — for metrics like churn or costs, negate deltaPct (and restate the sign in formatDelta, which controls the text only, never the color). label / current / previous / periodLabel are consumer-provided values — pass pre-formatted, translated values; a node value is a snippet. formatDelta is a snippet taking the delta.