@molecule/app-comparison-row-vue
Feature · comparison-row · App (browser) · v1.1.3 · Apache-2.0
Period-over-period stat comparison ("$X vs $Y", with delta)
npm install @molecule/app-comparison-row-vueHow it works
@molecule/app-comparison-row-vue 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.
import { createApp, defineComponent, h } from 'vue'
import { ComparisonRow } from '@molecule/app-comparison-row-vue'
const App = defineComponent({
setup() {
return () =>
h(ComparisonRow, {
label: 'Revenue',
current: '$24,800',
previous: '$21,300',
deltaPct: 16.4,
periodLabel: 'vs. last month',
})
},
})
createApp(App).mount('#app')Works with: @molecule/app-ui, @molecule/app-ui-vue, @molecule/app-vue
Reference
Vue period-over-period stat comparison row — the Vue 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.tsJSDoc, not this file.
Quick Start
import { createApp, defineComponent, h } from 'vue'
import { ComparisonRow } from '@molecule/app-comparison-row-vue'
const App = defineComponent({
setup() {
return () =>
h(ComparisonRow, {
label: 'Revenue',
current: '$24,800',
previous: '$21,300',
deltaPct: 16.4,
periodLabel: 'vs. last month',
})
},
})
createApp(App).mount('#app')
Type
feature
Installation
npm install @molecule/app-comparison-row-vue @molecule/app-ui @molecule/app-ui-vue @molecule/app-vue vue
API
Interfaces
ComparisonRowProps
Props accepted by the ComparisonRow component.
interface ComparisonRowProps {
/** Label for the metric (e.g. "Revenue"). */
label: VNodeChild
/** Current period value (formatted). */
current: VNodeChild
/** Previous period value (formatted). */
previous?: VNodeChild
/** Numeric delta% — drives direction + color when present. */
deltaPct?: number
/** Custom delta formatter. */
formatDelta?: (deltaPct: number) => VNodeChild
/** Optional sub-text ("vs. last week"). */
periodLabel?: VNodeChild
/** Extra classes. */
className?: string
}
Constants
ComparisonRow
Period-over-period stat comparison row — current value, optional previous value, and a coloured delta% chip. Used in dashboards, report summaries, finance overviews.
const ComparisonRow: DefineComponent<
ExtractPropTypes<{
label: null
current: null
previous: null
deltaPct: { type: NumberConstructor; default: undefined }
formatDelta: { type: PropType<(deltaPct: number) => VNodeChild>; default: undefined }
periodLabel: null
className: { type: StringConstructor; default: undefined }
}>,
() => VNode,
{},
{},
{},
ComponentOptionsMixin,
ComponentOptionsMixin,
{},
string,
PublicProps,
Readonly<
ExtractPropTypes<{
label: null
current: null
previous: null
deltaPct: { type: NumberConstructor; default: undefined }
formatDelta: { type: PropType<(deltaPct: number) => VNodeChild>; default: undefined }
periodLabel: null
className: { type: StringConstructor; default: undefined }
}>
> &
Readonly<{}>,
{ deltaPct: number; formatDelta: (deltaPct: number) => VNodeChild; className: string },
{},
{},
{},
string,
ComponentProvideOptions,
true,
{},
any
>
props— Component props (seeComparisonRowProps).
Returns: The comparison row component.
Injection Notes
Requirements
Peer dependencies:
@molecule/app-ui^1.4.0@molecule/app-ui-vue^1.1.0@molecule/app-vue^3.13.0 || ^4.0.0vue^3.4.0
Runtime Dependencies
@molecule/app-ui@molecule/app-ui-vue@molecule/app-vuevue
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 nodes — pass pre-formatted, translated values. A
node-valued prop arrives as a prop AND a same-named slot; components
accept either.