- Prop
amount- Type
number- Default
- —
- Requirement
- required
- Description
- Current price in minor units (e.g.
Docs Components Commerce
Price
React example follows below.
Vue example follows below.
Angular example follows below.
Svelte example follows below.
Solid example follows below.
- parts
- —
- nodes
- —
- size
- —
- part
- —
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> );}- parts
- —
- nodes
- —
- size
- —
- part
- —
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>- parts
- —
- nodes
- —
- size
- —
- part
- —
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;- parts
- —
- nodes
- —
- size
- —
- part
- —
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>- parts
- —
- nodes
- —
- size
- —
- part
- —
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
amountnumber—
required
Current price in minor units (e.g.
currencystring | undefined"USD"optional
ISO 4217 currency code.
compareAtnumber | undefined—
optional
Original price in minor units — struck through when greater than `amount`.
localestring | undefined—
optional
BCP-47 locale; defaults to the runtime locale.
size"sm" | "md" | "lg" | undefined"md"optional
—
- 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
amountnumber—
required
currencystring | undefined"USD"optional
compareAtnumber | undefined—
optional
localestring | 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
amountnumber—
required
currencystring"USD"optional
compareAtnumber—
optional
localestring—
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
amountnumber—
required
currencystring"USD"optional
compareAtnumber—
optional
localestring—
optional
size"sm" | "md" | "lg""md"optional
classNamestring—
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
amountnumber—
required
currencystring"USD"optional
compareAtnumber—
optional
localestring—
optional
size"sm" | "md" | "lg""md"optional
classNamestring—
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