Beautiful, dynamic price displays for calculators, e-commerce forms, and quote builders. Price displays are essential for showing computed totals, discounts, and formatted currency values that update in real-time.
Every code snippet below is fully editable! Feel free to modify the code, experiment with different values, and see your changes reflected instantly in the live preview on the right.
Use the play button to run different snippet, or the refresh button to restore the original example.
Let's start with an empty form function. This is where we'll build our price display form step by step.
Let's add a simple price display showing a static value. Price displays are read-only components that show formatted currency values.
addPriceDisplay() with a computedValue function that returns the price. The value is automatically formatted with currency symbol and decimals. Now let's make the price dynamic by connecting it to a slider. As the quantity changes, the total price updates automatically.
computedValue function is called reactively whenever dependent values change. Access slider values with form.slider('id')?.value(). Price displays come in four visual variants to match different use cases. Each variant has its own styling to convey meaning.
Show original prices with strikethrough when displaying discounts. This creates a compelling visual comparison that highlights savings.
originalPrice to show the pre-discount value with strikethrough. Return null when there's no discount to hide it. The savings badge appears automatically! Customize the currency symbol and its position. Support for international currencies and different formatting conventions.
currency sets the symbol (e.g., "$", "€", "£", "zł")currencyPosition controls placement: "before" ($100) or "after" (100$)decimals sets decimal places (0-3) Add contextual text before or after the price for additional meaning. Perfect for subscription pricing, per-unit costs, or totals.
prefix adds text before the price (e.g., "Starting at", "Only", "From")suffix adds text after (e.g., "/month", "/person", "USD") Control how prices are aligned within their container. Different alignments work better in different layouts.
alignment with "left", "center", or "right". Center alignment works great for hero prices, while right alignment is perfect for invoice totals. Let's build a complete service quote calculator combining everything we've learned. Multiple inputs affect the final price with premium options.
originalPrice shows the base price when premium options are selected! Excellent! You've mastered price displays and learned how to build interactive calculators with beautiful pricing UI. Ready to explore more?
Explore Slider TutorialOther learning paths: