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
symbolstring-Ticker. Used in fallback icon (first 2 chars).
namestring-Full name (e.g. "Apple Inc.").
sharesnumber-Held quantity. Fractional ok for crypto.
avgCostnumber-Average cost basis per share.
currentPricenumber-Last trade price.
currencystring"USD"ISO 4217 currency code.
localestring"en-US"Locale for Intl formatting.
seriesnumber[]-Recent prices for sparkline.
dayChangePctnumber-Day-change chip. Sign drives color.
iconReactNode-Override the symbol-letter avatar.
onClick() => void-Makes the card a focusable button.