PureAdmin.Components.Stat (PureAdmin v1.1.0)

Copy Markdown View Source

Stat and metric display components for Pure Admin.

Supports multiple variants: default (with optional icon), hero, hero-compact, and square.

Summary

Functions

Renders a stat display.

Functions

stat(assigns)

Renders a stat display.

Variants

  • default: Simple number + label (optionally with icon)
  • "hero": Large prominent stat with change indicator
  • "hero-compact": Compact hero variant
  • "square": Colored square stat with optional symbol

Examples

<.stat number="1,234" label_text="Total Users" />

<.stat variant="hero" number="$12,345" label_text="Revenue"
  change_text="+12.5%" change_direction="positive" />

<.stat variant="square" color="primary" number="42" label_text="Tasks" />

<.stat number="99.9%" label_text="Uptime" icon_variant="success">
  <:icon><i class="fa-solid fa-check-circle"></i></:icon>
</.stat>

Attributes

  • variant (:string) - Stat display variant. Defaults to nil. Must be one of nil, "hero", "hero-compact", or "square".
  • color (:string) - Color for square variant. Defaults to nil. Must be one of nil, "primary", "secondary", "success", "info", "warning", or "danger".
  • icon_variant (:string) - Icon color variant. Defaults to "primary". Must be one of "primary", "secondary", "success", "info", "warning", or "danger".
  • number (:string) - Value to display. Defaults to nil.
  • label_text (:string) - Label text. Defaults to nil.
  • change_text (:string) - Change text (e.g. '+12.5%') for hero variant. Defaults to nil.
  • change_direction (:string) - Change direction (determines color). Defaults to nil. Must be one of nil, "positive", "negative", or "neutral".
  • symbol_text (:string) - Symbol text for square variant. Defaults to nil.
  • value (:string) - Legacy alias for number. Defaults to nil.
  • label (:string) - Legacy alias for label_text. Defaults to nil.
  • trend (:string) - Legacy alias for change_text. Defaults to nil.
  • trend_direction (:string) - Legacy alias for change_direction (up/down). Defaults to nil.
  • class (:string) - Defaults to nil.
  • Global attributes are accepted.

Slots

  • icon - Icon content.
  • inner_block - Custom layout content (overrides default rendering).