Positions table
A React component in Beamline's Trading category.
Open positions with live unrealised PnL, liquidation warnings and close actions.
Use it for
- Under the chart in a terminal; portfolio pages.
- A narrow panel (figures join the name line) or a wide one (every figure in its column).
Not for
- Order history → data-grid.
Anatomy
- header row (same height as body rows)
- row (symbol with Long/Short word badge and leverage, size, entry, mark, liquidation with 'near' word, PnL with ▲/▼ and %, Close)
- name line (narrow room: size · entry → mark · Liq., under the symbol)
- pinned symbol column (clear at rest, opaque with a seam once scrolled)
- footer (count · total PnL with ▲/▼)
- empty text
Variants
- density: compact, default
States
- live PnL
- current market (value: aria-current, accent tint and a rule at the inline start)
- near liquidation (orange + word, in its column or in the name line)
- row hover / focus inside (a far liquidation in the name line arrives with attention)
- room: under 48rem size, entry → mark and liquidation join the name line and PnL stacks its %; under 26rem Close is its icon (its label stays for assistive tech); from 48rem every figure has its column
- scrolled (pinned column opaque with a seam)
- empty
Keyboard
- Symbol and Close are buttons in reading order.
Motion
Closing a position closes the gap: the rows below slide up (--pui-duration-standard). PnL updates in place; row hover arrives at once. Removing a row moves focus to the next row's Close. A change of room changes structure at the step (columns join the name line or separate) without moving anything else; the far liquidation's reveal arrives at once and leaves over --pui-motion-out.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
positions (required) | Position[] | — | Open positions supplied by the trading account. Required. |
onClose | (p) => void | — | Adds a close button per row. |
onSelect | (symbol) => void | — | Called when an item is activated; no handler by default. |
value | string | null | — | The market on screen: its rows are marked (aria-current; a tint and a rule at the inline start). |
priceDecimals | (symbol) => number | — | Returns the price precision for a market symbol. Defaults to the component price precision. |
density | 'compact'|'default'|'comfortable' | — | Row spacing; defaults to the scoped component or root density, then the stylesheet's default density. |
style / ref | CSSProperties / native Ref | — | style: Inline styles on the documented visual root; no inline overrides by default. ref: Receives the documented root element; no ref by default. |
classNames | PositionsTableClassNames | — | Classes for the named visual parts; no part overrides by default. |
style | CSSProperties | — | Inline styles on the documented visual root; no inline overrides by default. |
sizeDecimals | number | — | Maximum fractional digits used for trade sizes. Defaults to 4. |
quote | string | — | Quote currency shown with prices or totals. Defaults to "USD". |
emptyLabel | string | — | Message shown when no data is available. Defaults to "No open positions". |
className | string | — | Classes on the documented visual root; no override by default. |
ref | Ref<HTMLDivElement> | — | Receives the documented root element; no ref by default. |
getRowId | ((position: Position) => string) | — | Stable account position ID; defaults to symbol + side. |
manual | boolean | — | Server owns ordering, filters, search and page slicing. Default false. |
sort | ListSort | — | |
defaultSort | ListSort | — | |
onSortChange | ((sort: ListSort) => void) | — | |
filters | ListFilters | — | |
defaultFilters | ListFilters | — | |
onFiltersChange | ((filters: ListFilters) => void) | — | |
query | string | — | |
defaultQuery | string | — | |
onQueryChange | ((query: string) => void) | — | |
selected | string[] | — | Stable row IDs, retained across server pages. |
defaultSelected | string[] | — | |
onSelectedChange | ((ids: string[]) => void) | — | |
selectable | boolean | — | |
loading | boolean | — | |
error | ReactNode | Error | — | Errors retain the last completed rows. Error objects are rendered by their message. |
onRetry | (() => void | Promise<unknown>) | — | |
allowSelectAllMatching | boolean | — | |
onSelectAllMatching | ((scope: { rowCount: number; query: string; filters: ListFilters; }) => void) | — | |
pagination | boolean | — | Enable page controls explicitly. Page-related props also enable them, unless onEndReached is supplied. |
page | number | — | One-based requested page. Default 1. |
defaultPage | number | — | |
onPageChange | ((page: number) => void) | — | |
pageSize | number | — | Positive rows per page. Default 25. |
defaultPageSize | number | — | |
onPageSizeChange | ((pageSize: number) => void) | — | |
rowCount | number | null | — | Total matching rows on the server. null means unknown. Local grids calculate it before slicing. |
total | number | null | — | Deprecated: Use rowCount. Canonical rowCount wins, including null. |
onEndReached | (() => void | Promise<unknown>) | — | Append mode: fetch another batch. The app appends it to the supplied rows. |
hasMore | boolean | — | Whether another batch exists; defaults to true with onEndReached. False stops requests. |
loadingMore | boolean | — | An append request is pending; retain every loaded row. |
Built from
Used in
Dependencies
lucide-react
Import
import { PositionsTable } from "@beamline/positions-table";
Get it
Positions table is part of Beamline UI. Install the parts you need in your React app as compiled packages or editable source. Get Beamline · Connect your agent
More in Trading
- Price chart: Candles, line or area price chart with volume, OHLC legend and reference lines, built for live ticks.
- Market heatmap: Treemap of markets sized by weight and coloured by change, grouped by sector, with hatched no-data tiles.
- Order book: Asks, spread and bids with cumulative depth bars, grouping, change flashes and keyboard price picking.
- Options chain: Calls and puts for one expiry around a centre column of strikes: bid, ask, implied volatility, delta, volume and open interest, the money shaded in, a…
- Depth chart: Cumulative bid and ask depth as stepped areas around the mid, with hover readout.
- Ticker tape: A continuously scrolling row of symbols with price, change and mini trend; anyone can hold it: hover, keyboard focus or a tap.
- Watchlist: A selectable, sortable list of markets with mini trends, prices, changes and stars.
- Trades tape: Recent trades, newest first, with side glyphs, large-print marking and one-time arrival flashes.
- Order ticket: Buy/sell order entry with limit, market and stop types, % of balance, inline validation and a live cost summary.
- Swap form: Exchange one token for another: type what you pay (or Max), pick each token from a searchable list with balances, and the form quotes what you receive…
- P&L calendar: A trader's month at a glance: every trading day's profit or loss in its cell, shaded deeper the bigger it was in the gain or loss colour and marked ▲ or…
- Price ticker: Symbol, last price with a directional flash, 24h change and stats.
- Funding countdown: Perpetual funding rate with who pays, and a live countdown ring to the next funding.