Price
HkPrice is the money-display atom: a currency code's minor-unit digits (or an explicit precision), an optional unit suffix such as /1M, an optional reference conversion, and tabular-nums so a column of figures aligns digit-for-digit. It never guesses: an unfilled amount is a calm em dash with a "Not set" accessible name, and a reference conversion renders only when its rate is a finite number above zero.
- For a value that animates while the user watches, use HkRollingNumber; the price is a still figure.
- For an editable amount, the field is HkMoneyInput's job, not this component's: HkPrice has no input, no focus target and no model.
- A proportion of a total ("8,231 of 20,000") is HkShareBar's job; a price is one amount, not a ratio.
Import
import { HkPrice, type HkCurrency } from "@celestia-island/hikari";
const usd: HkCurrency = { code: "USD", symbol: "$", decimals: 2 };
export default () => <HkPrice amount={42} currency={usd} />;
import { HkPrice, type HkCurrency } from "@celestia-island/hikari";
const usd: HkCurrency = { code: "USD", symbol: "$", decimals: 2 };
export default () => <HkPrice amount={42} currency={usd} />;currency is a plain object — { code, symbol?, name?, decimals } — not a code string: the minor-unit digit count is what decides the default precision, so a host that already holds a settings row passes it as is. normalizeCurrency trims and upper-cases the code, forces decimals into 0..8 and drops an empty symbol, so a half-filled row renders instead of throwing.
Amounts and precision
amount is in currency's major units and is formatted with the currency's minor-unit digits unless precision overrides them (clamped to 0..8). Grouping is , every three integer digits and the decimal separator is . in every locale, so the displayed text round-trips through a parser and can never be read as a different number. unit is a plain suffix rendered after the amount.
The symbol is decorative (aria-hidden): the spoken name is the currency code, because a bare $ is ambiguous between USD, CAD and AUD.
$USD1,234.50¥JPY1,235KDKWD1,234.500$USD0.000420/1M
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import { HkPrice } from "@celestia-island/hikari";
import type { HkCurrency } from "@celestia-island/hikari";
import type { CSSProperties } from "vue";
const usd: HkCurrency = { code: "USD", symbol: "$", decimals: 2 };
const jpy: HkCurrency = { code: "JPY", symbol: "¥", decimals: 0 };
const kwd: HkCurrency = { code: "KWD", symbol: "KD", decimals: 3 };
const column: CSSProperties = { display: "grid", gap: "8px" };
export default () => (
<div style={column}>
<HkPrice amount={1234.5} currency={usd} />
<HkPrice amount={1234.5} currency={jpy} />
<HkPrice amount={1234.5} currency={kwd} />
<HkPrice amount={0.00042} currency={usd} unit="/1M" precision={6} />
</div>
);
import { HkPrice } from "@celestia-island/hikari";
import type { HkCurrency } from "@celestia-island/hikari";
import type { CSSProperties } from "vue";
const usd: HkCurrency = { code: "USD", symbol: "$", decimals: 2 };
const jpy: HkCurrency = { code: "JPY", symbol: "¥", decimals: 0 };
const kwd: HkCurrency = { code: "KWD", symbol: "KD", decimals: 3 };
const column: CSSProperties = { display: "grid", gap: "8px" };
export default () => (
<div style={column}>
<HkPrice amount={1234.5} currency={usd} />
<HkPrice amount={1234.5} currency={jpy} />
<HkPrice amount={1234.5} currency={kwd} />
<HkPrice amount={0.00042} currency={usd} unit="/1M" precision={6} />
</div>
);An unset amount
null, undefined and non-finite amounts were never a price of zero: they render an em dash with the accessible name "Not set", in quiet ink. A zero amount is a real amount and renders 0.00.
import { HkPrice } from "@celestia-island/hikari";
import type { HkCurrency } from "@celestia-island/hikari";
import type { CSSProperties } from "vue";
const usd: HkCurrency = { code: "USD", symbol: "$", decimals: 2 };
const column: CSSProperties = { display: "grid", gap: "8px" };
export default () => (
<div style={column}>
<HkPrice amount={null} currency={usd} />
<HkPrice amount={0} currency={usd} />
</div>
);
import { HkPrice } from "@celestia-island/hikari";
import type { HkCurrency } from "@celestia-island/hikari";
import type { CSSProperties } from "vue";
const usd: HkCurrency = { code: "USD", symbol: "$", decimals: 2 };
const column: CSSProperties = { display: "grid", gap: "8px" };
export default () => (
<div style={column}>
<HkPrice amount={null} currency={usd} />
<HkPrice amount={0} currency={usd} />
</div>
);Reference conversion
reference is { currency, rate, asOf? }, where rate is how many reference units one primary unit buys and asOf is an opaque host-formatted timestamp the component never parses. The conversion renders as a secondary "≈" figure only when the rate is a finite number above zero; a missing, zero, negative or NaN rate renders the primary amount alone, because an amount is never converted by a guessed rate. The audit line — "Approximate · 1 USD = 0.92 EUR · As of <date>" — is both the tooltip and the native title, so the figure stays auditable without hover.
The reference span is focusable (tabindex=0) so the tooltip opens from the keyboard as well as from the pointer.
$USD42.00Approximate≈€EUR38.64$USD42.00
import { HkPrice } from "@celestia-island/hikari";
import type { HkCurrency, HkPriceReference } from "@celestia-island/hikari";
import type { CSSProperties } from "vue";
const usd: HkCurrency = { code: "USD", symbol: "$", decimals: 2 };
const eur: HkCurrency = { code: "EUR", symbol: "€", decimals: 2 };
const reference: HkPriceReference = { currency: eur, rate: 0.92, asOf: "2026-12-03" };
const withoutRate: HkPriceReference = { currency: eur, rate: 0 };
const column: CSSProperties = { display: "grid", gap: "8px" };
export default () => (
<div style={column}>
<HkPrice amount={42} currency={usd} reference={reference} />
<HkPrice amount={42} currency={usd} reference={withoutRate} />
</div>
);
import { HkPrice } from "@celestia-island/hikari";
import type { HkCurrency, HkPriceReference } from "@celestia-island/hikari";
import type { CSSProperties } from "vue";
const usd: HkCurrency = { code: "USD", symbol: "$", decimals: 2 };
const eur: HkCurrency = { code: "EUR", symbol: "€", decimals: 2 };
const reference: HkPriceReference = { currency: eur, rate: 0.92, asOf: "2026-12-03" };
const withoutRate: HkPriceReference = { currency: eur, rate: 0 };
const column: CSSProperties = { display: "grid", gap: "8px" };
export default () => (
<div style={column}>
<HkPrice amount={42} currency={usd} reference={reference} />
<HkPrice amount={42} currency={usd} reference={withoutRate} />
</div>
);Shape and size
variant picks the skeleton: text (the default) for prose and detail rows, chip for a pill in a dense table; size is md (the default) or sm. Both keep the figures tabular and only the surrounding type scales.
import { HkPrice } from "@celestia-island/hikari";
import type { HkCurrency } from "@celestia-island/hikari";
import type { CSSProperties } from "vue";
const usd: HkCurrency = { code: "USD", symbol: "$", decimals: 2 };
const row: CSSProperties = { display: "flex", gap: "12px", alignItems: "center" };
export default () => (
<div style={row}>
<HkPrice amount={12.5} currency={usd} variant="text" size="md" />
<HkPrice amount={12.5} currency={usd} variant="chip" size="sm" />
</div>
);
import { HkPrice } from "@celestia-island/hikari";
import type { HkCurrency } from "@celestia-island/hikari";
import type { CSSProperties } from "vue";
const usd: HkCurrency = { code: "USD", symbol: "$", decimals: 2 };
const row: CSSProperties = { display: "flex", gap: "12px", alignItems: "center" };
export default () => (
<div style={row}>
<HkPrice amount={12.5} currency={usd} variant="text" size="md" />
<HkPrice amount={12.5} currency={usd} variant="chip" size="sm" />
</div>
);
API
Vue
Props
Accessibility
- The symbol is decorative (aria-hidden="true"); the currency code is rendered as visually hidden text inside the primary span, so the spoken reading is "USD 1,234.50" rather than an ambiguous "$1,234.50".
- An unset amount announces "Not set" from a visually hidden span; the em dash itself is aria-hidden.
- The reference figure is prefixed by a visually hidden "Approximate" and followed by the reference code; the conversion's evidence (rate and as-of stamp) is the title and the tooltip text, so it is reachable by hover, by focus and by copy.
- The reference span is a tabindex="0" stop with a focus-visible outline; a static amount adds no stop of its own.
- Digits are tabular-nums, so a column does not shift when the values change.
Related components
- HkRollingNumber — a figure that rolls when it changes, for live readouts.
- HkShareBar — the proportion bar for an "X of Y" breakdown.
- HkCopyBadge — the interactive tag, when the figure is an identifier that should be copied.
- Comment — the comment block, when a price is part of a threaded note.
- HkTag — the static label pill, when the text is a category rather than a figure.