Widgets
A compact Pro markets card with SVG sparklines, signed changes and host-owned paging.
This page covers MarketsWidget, the first component of the Pro widgets catalogue: a compact card of
market rows with an SVG sparkline, a signed change and host-owned pagination.
The widget ships from @unifin/chart-react/widgets and carries no chart, canvas or data feed. Rows
arrive from the host; the component never fetches, subscribes or stores them.
Widget catalogue
| Widget | Import | Status | Surface |
|---|---|---|---|
MarketsWidget | @unifin/chart-react/widgets | Beta | Five market rows, one SVG sparkline per row, a signed change, optional page dots, a footer link and an optional menu trigger |
Try it live
Markets
- +1.39%3,215.91
- -0.96%83.0705
- -0.78%93.3629
- +0.42%1,137.45
- +0.14%107.69
The card opens on the light palette. The dots switch five prepared lists and the menu trigger opens a panel drawn by the host.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
title | string | required | Card title, for example Markets |
items | readonly MarketsWidgetItem[] | required | Rows of the current page; the component neither slices nor sorts them |
locale | LocaleCode | ru | Number formats and accessible texts; uz and kz use the English accessible texts |
theme | ChartTheme | neutral CSS values | Colors and radius; every missing token falls back on its own |
pagination | MarketsWidgetPagination | none | Controlled page dots; without the prop there are no dots |
footerLink | MarketsWidgetFooterLink | none | Footer link; a missing or unsafe href removes the link |
onMenu | () => void | none | Menu trigger; without the prop the ellipsis button is not rendered |
asOf | number | none | Snapshot time in epoch milliseconds, read only through aria-description |
labels | Partial<MarketsWidgetLabels> | RU/EN catalogue | Accessible text overrides; an empty string falls back to the default |
formatValue | (item, locale) => string | built-in format | Host value formatter; an exception or an empty string falls back to the default |
formatChange | (item, locale) => string | built-in format | Host change formatter; an exception or an empty string falls back to the default |
className | string | none | Host class for the outer layout; colors and radius stay in the theme |
ariaLabel | string | title | Accessible name of the card section |
Item fields
| Field | Type | Default | Description |
|---|---|---|---|
id | string | required | Unique key of the row within the page |
symbol | string | required | Ticker or short instrument code, for example IMOEX |
name | string | symbol | Display name; a long name is truncated with the full value in title |
value | number | none | Numeric value formatted through formatNumber |
formattedValue | string | none | Ready value from the host; wins over value and formatValue |
valueDigits | number | 2 | Fraction digits of the default value format, clamped to 0..8 |
change | number | none | Change in percentage points: 1.39 means +1.39% |
formattedChange | string | none | Ready change from the host; wins over change and formatChange |
trend | readonly number[] | none | Sparkline series; non-finite points are skipped |
Import and render
import { useState } from 'react';
import { MarketsWidget, type MarketsWidgetItem } from '@unifin/chart-react/widgets';
const PAGES: readonly (readonly MarketsWidgetItem[])[] = [
[
{ id: 'imoex', symbol: 'IMOEX', name: 'Moscow Exchange Index', value: 3215.91, change: 1.39, trend: [3118, 3141, 3168, 3215.91] },
{ id: 'usdrub', symbol: 'USD/RUB', value: 83.0705, valueDigits: 4, change: -0.96, trend: [84.31, 83.97, 83.48, 83.0705] },
],
[{ id: 'brent', symbol: 'BRENT', value: 74.18, change: 0.63, trend: [72.85, 73.26, 73.72, 74.18] }],
];
export function MarketsCard() {
const [page, setPage] = useState(0);
return (
<MarketsWidget
title="Markets"
items={PAGES[page] ?? []}
locale="en"
pagination={{ pages: PAGES.length, current: page, onChange: setPage }}
footerLink={{ label: 'View the market', href: '/docs/kits' }}
/>
);
}The host keeps the page index and passes the rows of that page. pages counts pages, current is a
0-based index, and the active dot never calls onChange.
Formatting and locales
Value priority is formattedValue, then formatValue, then value with valueDigits. Change
priority is formattedChange, then formatChange, then change with a sign and a percent suffix.
NaNandInfinityrender as-.engroups thousands with a comma and separates decimals with a dot:3,215.91.rugroups thousands with a space and separates decimals with a comma:3 215,91.- An exception in a host formatter does not escape: the built-in format takes over.
Note The
localeprop defaults toru. Passenfor an English card, as the live demo does.
Themes
The card paints only from the ChartTheme you pass: panel, grid, text, muted text, accent, up, down
and radius. Missing tokens resolve one by one, so a partial theme stays renderable.
Without a theme, the card uses neutral CSS values: a transparent surface, the surrounding text
color and the inherited font. Pass a palette object for a colored card.
import { LIGHT_THEME } from '@unifin/chart-core';
import { MarketsWidget, type MarketsWidgetItem } from '@unifin/chart-react/widgets';
const rows: readonly MarketsWidgetItem[] = [
{ id: 'rgbi', symbol: 'RGBI', name: 'Moscow Exchange Government Bond Index', value: 107.69, change: 0.14 },
];
<MarketsWidget title="Markets" items={rows} locale="en" theme={LIGHT_THEME} />;No stylesheet is required. className adds outer layout only; colors and radius remain in the theme,
so a white-label host repaints the card through its own palette.
Accessibility
- The card is a section named by
ariaLabel, or bytitlewhen the prop is absent. - Rows form a semantic list; every row carries an
aria-labelwith the name, ticker, change and value. - The sparkline is
aria-hidden: it repeats the numbers of its row. - Page dots are
<button type="button">with a 1-based label andaria-current="page"on the active dot. - The footer link is keyboard focusable; external
http(s)links receiverel="noopener noreferrer". asOfis exposed only as anaria-description, so the visual layout stays unchanged.
Server rendering
The component has no effects, no useId and no access to window, document or ResizeObserver.
renderToString returns the same markup on the server and in a second render; React 18 and React 19
are supported.
Caution
pagination.onChangeandonMenuare callbacks. Pass them from a client component; a server component can render the card itself but cannot hand it functions.
Budget and stability
The @unifin/chart-react/widgets subpath is budgeted at 6 KB gzip and the built entry measures
5.30 KB gzip. A host that does not import the subpath pays nothing extra.
Every export of the subpath is in beta. New optional props are additive; a breaking prop change follows the major version.
See also
- Pro edition - the entry points, the surfaces and the budgets.
- Terminal panels - the canvas panel family of the Pro entry point.
- Analytics kits - the board pages the footer link opens.
- Editions - the size budgets of every entry point.
Terminal panels
The five Pro terminal panels - liquidity ribbon, delta candles, pace of tape, auction landscape and efficient frontier, with the models behind them.
Drawing dashboard
The Pro drawing surfaces over the live streaming chart - the tool rail with search and favorites, the floating figure style panel with fifteen fill patterns, style templates and the figure context menu.
