Market Table

A market list with price, change, volume and cap. Rank is the caller’s, never the row index — a re-sorted table that renumbers from one destroys the identifier people use to talk about a market.

src/components/ui/market-table.tsx

About

From the component's own source, where it was written.

A market list: price, change, volume, market cap.

Rank is the caller's, not the row index. A filtered or re-sorted table whose "#" column renumbers from one destroys the only stable identifier people use to talk about a market — "the number four coin" has to keep meaning the same asset when you sort by 24h change.

Watchlist state is reported, never held: a starred asset belongs to an account, not to a table that forgets on unmount.

Install

npx astralyx-ui add market-table

Usage

import { MarketTable } from '@/components/ui/market-table'

<MarketTable markets={markets} onStar={star} onSelect={open} />

Composer

Change the props and the source below follows.

#Market
1BTCBitcoinUS$67,240.12+2.41%
2ETHEthereumUS$3,284.50-1.12%
3SOLSolanaUS$178.32+5.87%
4USDCUSD CoinUS$1.00+0.01%
5PEPEPepeUS$0.0000-8.44%
Props
tsx
<MarketTable markets={markets} onStar={star} onSelect={open} />

Examples

Markets

API

Generated from the source, so it cannot fall behind the code. One table per exported component, then hooks, functions and types.

MarketTable

Extends Omit<ComponentProps<'div'>, 'onSelect'>.

PropTypeDefaultDescription
marketsMarket[]required{ id, rank?, symbol, name, price, change24h?, volume24h?, marketCap?, history?, starred? }.
currencystring'USD'—
localestring'en-GB'—
searchablebooleantrue—
onStar(id: string, starred: boolean) => void—Watchlist state is reported, never held — a starred asset belongs to an account, not a table that forgets on unmount.
onSelect(id: string) => void——
searchPlaceholderstring'Search markets'—
searchLabelstring'Search markets'Accessible name for the search field.
rankHeaderReactNode'#'—
marketHeaderReactNode'Market'—
priceHeaderstring'Price'—
changeHeaderstring'24h'—
volumeHeaderstring'Volume'—
capHeaderstring'Cap'—
starLabel(symbol: string, starred: boolean) => stringDEFAULT_STAR_LABELAccessible name for the star toggle.
emptyMessageReactNode'No markets match.'—

Types

Market

A market list: price, change, volume, market cap.

FieldTypeDescription
idstring—
rank?number—
symbolstring—
nameReactNode—
icon?ReactNode—
pricenumberSub-dollar assets get four digits; large caps use compact notation.
change24h?numberPercentage.
volume24h?number—
marketCap?number—
history?number[]—
starred?boolean—

Behaviour

TopicDetailDescription
columnsresponsiveVolume drops below sm, cap below md, the sparkline below lg. The table also scrolls rather than crushing.