Components/Portfolio Card

Portfolio Card

Single-position card. Market value, sparkline, day-change chip, and the full breakdown (shares, avg cost, last price, total return). Becomes a focusable button when onClick is passed.


Installation

npx ajaxui add portfolio-card

Grid layout

Cards have no fixed width — drop them into a grid and they fill the cell.

Crypto positions

Works for any asset — pass fractional shares for crypto holdings.

BTC

Bitcoin

2.34%

Market value

$17,677.13

Shares
0.2481
Avg cost
$42,000.00
Last
$71,250.00
Total return
+$7,256.93 (+69.64%)

ETH

Ethereum

0.81%

Market value

$12,243.60

Shares
3.42
Avg cost
$2,200.00
Last
$3,580.00
Total return
+$4,719.60 (+62.73%)

Props

PropTypeDefaultDescription
symbolstringTicker. Used in fallback icon (first 2 chars).
namestringFull name (e.g. "Apple Inc.").
sharesnumberHeld quantity. Fractional ok for crypto.
avgCostnumberAverage cost basis per share.
currentPricenumberLast trade price.
currencystring"USD"ISO 4217 currency code.
localestring"en-US"Locale for Intl formatting.
seriesnumber[]Recent prices for sparkline.
dayChangePctnumberDay-change chip. Sign drives color.
iconReactNodeOverride the symbol-letter avatar.
onClick() => voidMakes the card a focusable button.