PhoenixKitWeb.Components.Core.CurrencyDisplay (phoenix_kit v1.7.69)

Copy Markdown View Source

Provides currency formatting components for the billing system.

Supports formatting monetary amounts with currency symbols, locale-aware number formatting, and various display styles.

Summary

Functions

Formats and displays a monetary amount with currency symbol.

Displays a currency badge with symbol and name.

Displays currency with styling for positive/negative amounts.

Displays a compact currency amount, useful for tables and lists.

Functions

currency_amount(assigns)

Formats and displays a monetary amount with currency symbol.

Attributes

  • amount - Decimal or number to display (required)
  • currency - Currency code like "EUR", "USD" (default: "EUR")
  • symbol_position - :before or :after (default: :before)
  • show_code - Show currency code alongside symbol (default: false)
  • class - Additional CSS classes

Examples

<.currency_amount amount={99.99} />
<.currency_amount amount={@order.total} currency="USD" />
<.currency_amount amount={150.00} currency="EUR" show_code={true} />

Attributes

  • amount (:any) (required)
  • currency (:string) - Defaults to "EUR".
  • symbol_position (:atom) - Defaults to :before. Must be one of :before, or :after.
  • show_code (:boolean) - Defaults to false.
  • class (:string) - Defaults to "".

currency_badge(assigns)

Displays a currency badge with symbol and name.

Attributes

  • code - Currency code like "EUR", "USD" (required)
  • name - Currency name (optional, will be looked up if not provided)
  • size - Badge size: :xs, :sm, :md, :lg (default: :sm)
  • class - Additional CSS classes

Examples

<.currency_badge code="EUR" />
<.currency_badge code="USD" name="US Dollar" size={:md} />

Attributes

  • code (:string) (required)
  • name (:string) - Defaults to nil.
  • size (:atom) - Defaults to :sm. Must be one of :xs, :sm, :md, or :lg.
  • class (:string) - Defaults to "".

currency_colored(assigns)

Displays currency with styling for positive/negative amounts.

Attributes

  • amount - Decimal or number to display (required)
  • currency - Currency code (default: "EUR")
  • class - Additional CSS classes

Examples

<.currency_colored amount={100.00} />
<.currency_colored amount={-50.00} currency="USD" />

Attributes

  • amount (:any) (required)
  • currency (:string) - Defaults to "EUR".
  • class (:string) - Defaults to "".

currency_compact(assigns)

Displays a compact currency amount, useful for tables and lists.

Attributes

  • amount - Decimal or number to display (required)
  • currency - Currency code (default: "EUR")
  • class - Additional CSS classes

Examples

<.currency_compact amount={99.99} />
<.currency_compact amount={@invoice.total} currency="USD" />

Attributes

  • amount (:any) (required)
  • currency (:string) - Defaults to "EUR".
  • class (:string) - Defaults to "".