Docs Components Commerce

Price

React example follows below.
ts
const priceFixture = {
id: "price",
amount: 3200,
saleAmount: 8900,
saleCompareAt: 10400,
saleSize: "lg",
localizedAmount: 1800,
localizedCurrency: "EUR",
localizedLocale: "de-DE",
} satisfies {
id: string;
amount: number;
saleAmount: number;
saleCompareAt: number;
saleSize: "sm" | "md" | "lg";
localizedAmount: number;
localizedCurrency: string;
localizedLocale: string;
};
import { Price } from "@grassroot/ui-react";
export default function PriceDemo() {
return (
<div>
<Price amount={priceFixture.amount} />
<Price
amount={priceFixture.saleAmount}
compareAt={priceFixture.saleCompareAt}
size={priceFixture.saleSize}
/>
<Price
amount={priceFixture.localizedAmount}
currency={priceFixture.localizedCurrency}
locale={priceFixture.localizedLocale}
/>
</div>
);
}
ts
<script setup lang="ts">
const priceFixture = {
id: "price",
amount: 3200,
saleAmount: 8900,
saleCompareAt: 10400,
saleSize: "lg",
localizedAmount: 1800,
localizedCurrency: "EUR",
localizedLocale: "de-DE",
} satisfies {
id: string;
amount: number;
saleAmount: number;
saleCompareAt: number;
saleSize: "sm" | "md" | "lg";
localizedAmount: number;
localizedCurrency: string;
localizedLocale: string;
};
import { Price } from "@grassroot/ui-vue";
</script>
<template>
<div>
<Price :amount="priceFixture.amount" />
<Price
:amount="priceFixture.saleAmount"
:compare-at="priceFixture.saleCompareAt"
:size="priceFixture.saleSize"
/>
<Price
:amount="priceFixture.localizedAmount"
:currency="priceFixture.localizedCurrency"
:locale="priceFixture.localizedLocale"
/>
</div>
</template>
ts
import { Component } from "@angular/core";
const priceFixture = {
id: "price",
amount: 3200,
saleAmount: 8900,
saleCompareAt: 10400,
saleSize: "lg",
localizedAmount: 1800,
localizedCurrency: "EUR",
localizedLocale: "de-DE",
} satisfies {
id: string;
amount: number;
saleAmount: number;
saleCompareAt: number;
saleSize: "sm" | "md" | "lg";
localizedAmount: number;
localizedCurrency: string;
localizedLocale: string;
};
import { GrassrootPrice } from "@grassroot/ui-angular";
@Component({
selector: "app-price-demo",
standalone: true,
imports: [GrassrootPrice],
template: `
<div>
<grassroot-price [amount]="fixture.amount" />
<grassroot-price
[amount]="fixture.saleAmount"
[compareAt]="fixture.saleCompareAt"
[size]="fixture.saleSize"
/>
<grassroot-price
[amount]="fixture.localizedAmount"
[currency]="fixture.localizedCurrency"
[locale]="fixture.localizedLocale"
/>
</div>
`,
})
export class PriceDemoComponent {
protected readonly fixture = priceFixture;
}
export default PriceDemoComponent;
ts
<script lang="ts">
import { Price } from "@grassroot/ui-svelte";
const priceFixture = {
id: "price",
amount: 3200,
saleAmount: 8900,
saleCompareAt: 10400,
saleSize: "lg",
localizedAmount: 1800,
localizedCurrency: "EUR",
localizedLocale: "de-DE",
} satisfies {
id: string;
amount: number;
saleAmount: number;
saleCompareAt: number;
saleSize: "sm" | "md" | "lg";
localizedAmount: number;
localizedCurrency: string;
localizedLocale: string;
};
</script>
<div>
<Price amount={priceFixture.amount} /><Price
amount={priceFixture.saleAmount}
compareAt={priceFixture.saleCompareAt}
size={priceFixture.saleSize}
/><Price
amount={priceFixture.localizedAmount}
currency={priceFixture.localizedCurrency}
locale={priceFixture.localizedLocale}
/>
</div>
ts
/** @jsxImportSource solid-js */
import { Price } from "@grassroot/ui-solid";
const priceFixture = {
id: "price",
amount: 3200,
saleAmount: 8900,
saleCompareAt: 10400,
saleSize: "lg",
localizedAmount: 1800,
localizedCurrency: "EUR",
localizedLocale: "de-DE",
} satisfies {
id: string;
amount: number;
saleAmount: number;
saleCompareAt: number;
saleSize: "sm" | "md" | "lg";
localizedAmount: number;
localizedCurrency: string;
localizedLocale: string;
};
export default function PriceDemo() {
return (
<div>
<Price amount={priceFixture.amount} />
<Price
amount={priceFixture.saleAmount}
compareAt={priceFixture.saleCompareAt}
size={priceFixture.saleSize}
/>
<Price
amount={priceFixture.localizedAmount}
currency={priceFixture.localizedCurrency}
locale={priceFixture.localizedLocale}
/>
</div>
);
}

Installation

API Reference

Import

import { Price } from "@grassroot/ui-react";

Props

Prop
Type
Default
Requirement
Description
amount
number
required
Current price in minor units (e.g.
currency
string | undefined
"USD"
optional
ISO 4217 currency code.
compareAt
number | undefined
optional
Original price in minor units — struck through when greater than `amount`.
locale
string | undefined
optional
BCP-47 locale; defaults to the runtime locale.
size
"sm" | "md" | "lg" | undefined
"md"
optional
Prop
amount
Type
number
Default
Requirement
required
Description
Current price in minor units (e.g.
Prop
currency
Type
string | undefined
Default
"USD"
Requirement
optional
Description
ISO 4217 currency code.
Prop
compareAt
Type
number | undefined
Default
Requirement
optional
Description
Original price in minor units — struck through when greater than `amount`.
Prop
locale
Type
string | undefined
Default
Requirement
optional
Description
BCP-47 locale; defaults to the runtime locale.
Prop
size
Type
"sm" | "md" | "lg" | undefined
Default
"md"
Requirement
optional
Description

Native attributes

Standard DOM and ARIA attributes not listed above spread onto the root element.

Import

import { Price } from "@grassroot/ui-vue";

Props

Prop
Type
Default
Requirement
amount
number
required
currency
string | undefined
"USD"
optional
compareAt
number | undefined
optional
locale
string | undefined
optional
size
"sm" | "md" | "lg" | undefined
"md"
optional
Prop
amount
Type
number
Default
Requirement
required
Prop
currency
Type
string | undefined
Default
"USD"
Requirement
optional
Prop
compareAt
Type
number | undefined
Default
Requirement
optional
Prop
locale
Type
string | undefined
Default
Requirement
optional
Prop
size
Type
"sm" | "md" | "lg" | undefined
Default
"md"
Requirement
optional

Import

import { Component } from "@angular/core";
import { GrassrootPrice } from "@grassroot/ui-angular";

Props

Prop
Type
Default
Requirement
amount
number
required
currency
string
"USD"
optional
compareAt
number
optional
locale
string
optional
size
"sm" | "md" | "lg"
"md"
optional
Prop
amount
Type
number
Default
Requirement
required
Prop
currency
Type
string
Default
"USD"
Requirement
optional
Prop
compareAt
Type
number
Default
Requirement
optional
Prop
locale
Type
string
Default
Requirement
optional
Prop
size
Type
"sm" | "md" | "lg"
Default
"md"
Requirement
optional

Import

import { Price } from "@grassroot/ui-svelte";

Props

Prop
Type
Default
Requirement
amount
number
required
currency
string
"USD"
optional
compareAt
number
optional
locale
string
optional
size
"sm" | "md" | "lg"
"md"
optional
className
string
optional
Prop
amount
Type
number
Default
Requirement
required
Prop
currency
Type
string
Default
"USD"
Requirement
optional
Prop
compareAt
Type
number
Default
Requirement
optional
Prop
locale
Type
string
Default
Requirement
optional
Prop
size
Type
"sm" | "md" | "lg"
Default
"md"
Requirement
optional
Prop
className
Type
string
Default
Requirement
optional

Import

import { Price } from "@grassroot/ui-solid";

Props

Prop
Type
Default
Requirement
amount
number
required
currency
string
"USD"
optional
compareAt
number
optional
locale
string
optional
size
"sm" | "md" | "lg"
"md"
optional
className
string
optional
Prop
amount
Type
number
Default
Requirement
required
Prop
currency
Type
string
Default
"USD"
Requirement
optional
Prop
compareAt
Type
number
Default
Requirement
optional
Prop
locale
Type
string
Default
Requirement
optional
Prop
size
Type
"sm" | "md" | "lg"
Default
"md"
Requirement
optional
Prop
className
Type
string
Default
Requirement
optional