React Shared Components

Interactive testing environment for react-shared components

Theme Playground

Current: Default

PriceOff

Display discount badges showing percentage or absolute amount off the original price.

Interactive Playground

Customize the PriceOff properties and see the changes in real-time.

25%OFF

Examples

Common use cases and variations.

25% Off

25%OFF

50% Off

50%OFF

10% Off

10%OFF

$20 Off (Absolute)

20OFF

$50 Off (Absolute)

50OFF

75% Off (Big Sale)

75%OFF

API Reference

Complete list of props and their descriptions.

PropTypeDefaultDescription
amountnumberundefinedOriginal price amount
saleAmountnumberundefinedSale price amount
saleType'percent' | 'absolute''percent'Display type: percentage off or absolute amount off
classNamestring''Additional CSS classes

Usage Notes

Automatic Calculation

The component automatically calculates the discount based on the original amount and sale amount. For percentage type, it shows the percentage off. For absolute type, it shows the dollar amount saved.

Null Handling

If amount or saleAmount is missing, or if there's no actual discount, the component returns null and renders nothing.

Styling

The badge uses accent2 background color with secondary foreground text. It has rounded corners and compact padding for a clean, modern look.

Translation Support

The "OFF" text is internationalized using the useTranslation hook, supporting multiple languages.