Skip to content
ProLifetime access for $199, paid once, every future release included
Truffle UI

Stocks

ProNew

Market quotes as a ticker tape, card grid or stack, compact list, sortable watchlist or chart with range tabs. Quotes come from props.

Installation

pnpm dlx shadcn@latest add @viewport/stocks

First time? Add the @viewport registry to components.json. Setup takes one minute.

Usage

The code behind the preview above comes with Truffle Pro.

Props

<Stocks>

PropTypeDefault
quotes*Quote[]—
layout"ticker" | "cards" | "stack" | "list" | "watchlist" | "chart"

`ticker` is a scrolling tape, `cards` a grid, `stack` one card per row, `list` compact rows, `watchlist` a sortable table and `chart` one symbol with range tabs.

"cards"
titlestring

A heading above the widget.

—
currencystring"USD"
localestring"en-US"
colors"green-up" | "red-up"

`red-up` swaps the colors, as markets in East Asia do.

"green-up"
sparklinesboolean

Small charts in the ticker, cards, list and table.

true
onSelect(symbol: string) => void

Makes each symbol a button.

—
durationnumber

Ticker: seconds for one full loop.

—
rangesstring[]

Chart: range tabs. Defaults to the keys of the symbol's `ranges`.

—
rangestring

Chart: the open range, for controlled use (fetch the data in `onRangeChange`).

—
defaultRangestring—
onRangeChange(range: string) => void—
symbolstring

Chart: the symbol on show, for controlled use.

—
defaultSymbolstring—
onSymbolChange(symbol: string) => void—
footnoteReact.ReactNode

A line under the widget, such as "Delayed 15 minutes".

—
loadingboolean—
errorstring

An error message in place of the quotes, with a retry button when `onRetry` is set.

—
onRetry() => void—
classNamestring—

<Chart>

PropTypeDefault
quotes*Quote[]—
format*Format—

Accessibility

  • The tape has a pause button and also stops on hover or focus; under reduced motion it is a plain scrollable row.
  • Direction is never color alone: every change has an arrow and reads as “up” or “down”.
  • Watchlist headers are buttons that set aria-sort. Range tabs are a tablist with arrow keys.
  • The chart is a slider: arrow keys, Page Up/Down, Home and End read each price, and a status line announces the symbol when it changes.