Calm motion: animations on this site only fade, with no movement
Unit converter
An amount in one unit of measure and its value in another, such as boxes and pieces
Converts between the packs of one product in a warehouse or an ERP. For money, use the currency converter.
Basic
In whole units: 2 cartons, 3 boxes, 5 pcs
unitsis the list of units of one product. Each unit has anid, aname, andperBase: how many of the base unit are in one of it. The base unit has aperBaseof 1.v-model:amount,v-model:from, andv-model:tohold the amount and the two units. The ⇄ button swaps the units.- The result is an
outputelement, so screen readers hear each new value. - "In whole units" splits the amount into the largest whole units first, such as "2 cartons, 3 boxes, 5 pcs". A part that is not whole stays in the smallest unit.
localesets the format of the numbers. Change the words withlabelsor a label pack:amount,from,to,swap,result, andsplit.
The splitUnits function does the split. It is exported for your own views.
Usage
ts
import { BlessUnitConverter } from "blessing-ui";API
Props
| Name | Type | Default | Description |
|---|---|---|---|
units* | BlessUnit[] | — | |
locale | string | "en" | |
labels | Partial<{ amount: string; from: string; to: string; swap: string; result: string; split: string; }> | — | |
amount | number | 1 | |
from | string | — | |
to | string | — |
Events
| Name | Payload | Description |
|---|---|---|
update:amount | [value: number] | |
update:from | [value: string | undefined] | |
update:to | [value: string | undefined] |