Trivio Logo
Docs
v0.1.0
UI Components

@trivio.ink/react Quick Start

Ready-to-use React UI components, currency exponent formatters, and settlement summary trees.

Installation

npm install @trivio.ink/react @trivio.ink/core react react-dom

Pre-Built Components

Render accessible, currency-aware settlement summary cards in your frontend merchant portal:

PayoutCard.tsxtypescript
import React from "react";
import { 
  TrivioSettlementSummary, 
  TrivioFeeBreakdown,
  formatCurrency,
  formatMinorAmount,
  getCurrencyDecimals,
  type IntegratedSettlementEstimateResult
} from "@trivio.ink/react";

export function TransactionPayoutCard({ estimate }: { estimate: IntegratedSettlementEstimateResult }) {
  return (
    <div className="rounded-lg border border-gray-800 bg-gray-900 p-6 space-y-6">
      {/* 1. Complete settlement breakdown tree */}
      <TrivioSettlementSummary
        estimate={estimate}
        currencyCode="USD"
      />

      {/* 2. Itemized percentage and fixed fee breakdown */}
      <TrivioFeeBreakdown
        estimate={estimate}
        currencyCode="USD"
      />

      {/* 3. Direct currency formatting helper */}
      <p className="text-xs text-gray-400">
        Net deposit: {formatCurrency(estimate.netMinor, "USD")}
      </p>
    </div>
  );
};

Currency Exponent Awareness

The React SDK avoids naive / 100 division by referencing the official ISO 4217 currency exponent table:

formatCurrency(1500, 'JPY') -> 'JPY 1500' (0 decimals via getCurrencyDecimals)

formatCurrency(1000000, 'USD') -> 'USD 10,000.00' (2 decimals)

formatCurrency(1500, 'BHD') -> 'BHD 1.500' (3 decimals)

formatMinorAmount(1000000, 2) -> '10000.00' (direct decimal string)