Skip to content

Price Component ​

A business component for displaying prices, supporting differentiated font sizes for digits before and after the decimal point, enhancing the visual effect and readability of amounts.

📌 Platform Differences ​

APP(vue)H5WeChat Mini ProgramAlipay Mini Program
✔✔✔✔

Component Features ​

  • Differentiated Display: Automatically differentiates font sizes for digits before and after the decimal point, enhancing visual hierarchy
  • Flexible Configuration: Supports customizing style attributes such as color, size, weight, and slant
  • Multi-Currency Support: Customizable currency symbols to accommodate different currency needs
  • Formatting Control: Supports setting the number of decimal places for precise control over amount display
  • Responsive Design: Adapts to multiple platforms, maintaining consistent visual effects

🏯 Basic Usage Examples ​

vue
<!-- Global usage -->
<hy-price :text="price"></hy-price>
ts
const price = 10;

Setting Color ​

vue
<hy-price :text="price" color="#9CC53D"></hy-price>
ts
import { HyPrice } from '@hy-app/ui';

const price = 10;

Setting Size ​

vue
<hy-price :text="price" :size="20"></hy-price>
ts
import { HyPrice } from '@hy-app/ui';

const price = 10;

Decimal Places ​

vue
<hy-price :text="price" :num="6"></hy-price>
ts
import { HyPrice } from '@hy-app/ui';

const price = 10;

Setting Prefix Symbol ​

vue
<hy-price :text="price" symbol="$"></hy-price>
ts
import { HyPrice } from '@hy-app/ui';

const price = 10;

Setting Weight ​

vue
<hy-price :text="price" :weight="900"></hy-price>
ts
import { HyPrice } from '@hy-app/ui';

const price = 10;

Setting Slant ​

vue
<hy-price :text="price" :slant="true"></hy-price>
ts
import { HyPrice } from '@hy-app/ui';

const price = 10;

Setting Ratio ​

vue
<hy-price text="10.22" :ratio="1"></hy-price>
<hy-price text="10.22" :ratio="1.2"></hy-price>
<hy-price text="10.22"></hy-price>
<hy-price text="10.22" :ratio="1.6"></hy-price>
ts
import { HyPrice } from 'hy-app';

API ​

Price Props ​

ParameterDescriptionTypeDefault
textAmount valuestring | number0.00
symbolCurrency symbolstring¥
ratioRatio sizenumber1.4
numNumber of decimal places to keepnumber2
colorFont colorstring#FE3232
sizeFont size, default unit is px for numbersstring | number12
weightFont weightnumber500
slantWhether to slantbooleanfalse
customStyleCustom external styles to be appliedCSSProperties-
customClassCustom external class namestring-

Events ​

Event NameDescriptionCallback Parameters
clickClick on amounttext: Amount value

CSS Variables ​

Variable NameDescriptionDefault Value
--hy-price-font-sizeFont size32rpx
--hy-price-margin-topTop margin5px
12:33
battery