CLI previewInstall commands shown on this site are not released yet.

DocsComponentsCommerce

Price

React example follows below.
ts
import { Price } from "@grassroot/ui-react";
<Price amount={3200} />
<Price amount={8900} compareAt={10400} size="lg" />
<Price amount={1800} currency="EUR" locale="de-DE" />
ts
<script setup lang="ts">
import { Price } from "@grassroot/ui-vue";
</script>
<template>
<Price :amount="3200" />
<Price :amount="8900" :compare-at="10400" size="lg" />
<Price :amount="1800" currency="EUR" locale="de-DE" />
</template>
ts
import { Component } from "@angular/core";
import { GrassrootPrice } from "@grassroot/ui-angular";
@Component({
selector: "app-example",
standalone: true,
imports: [GrassrootPrice],
template: `
<grassroot-price [amount]="3200" />
<grassroot-price [amount]="8900" [compareAt]="10400" size="lg" />
<grassroot-price [amount]="1800" currency="EUR" locale="de-DE" />
`,
})
export class ExampleComponent {
}
ts
<script lang="ts">
import { Price } from "@grassroot/ui-svelte";
</script>
<Price amount={3200} />
<Price amount={8900} compareAt={10400} size="lg" />
<Price amount={1800} currency="EUR" locale="de-DE" />
ts
import { Price } from "@grassroot/ui-solid";
export function Example() {
return (
<>
<Price amount={3200} />
<Price amount={8900} compareAt={10400} size="lg" />
<Price amount={1800} currency="EUR" locale="de-DE" />
</>
);
}

Installation

bash
pnpm dlx grassroot add ui/price
bash
npx grassroot@latest add ui/price
bash
yarn dlx grassroot add ui/price
bash
bunx grassroot add ui/price

API Reference

PriceProps
PropTypeDefault
amountrequiredCurrent price in minor units (e.g. cents).number
currencyISO 4217 currency code.string | undefined"USD"
compareAtOriginal price in minor units — struck through when greater than `amount`.number | undefined
localeBCP-47 locale; defaults to the runtime locale.string | undefined
size"sm" | "md" | "lg" | undefined"md"