LanternUI.Components.Stat (LanternUI v0.8.2)

Copy Markdown View Source

Compact summary metrics extracted from the data table overview.

Use stat_card/1 for a single metric or compose one or more cards with the slot-driven stat_grid/1. Callers own calculations and formatting; these components only present concise labels, values, and optional context.

<.stat_card label="Open orders" value={42} icon="hero-inbox" />

<.stat_grid>
  <:stat label="Open" value={42} />
  <:stat label="Shipped" value={128} href="/orders?status=shipped" />
</.stat_grid>

Summary

Functions

Renders one compact summary metric.

Renders a responsive collection of summary metrics; emits nothing when empty.

Functions

stat_card(assigns)

Renders one compact summary metric.

Attributes

  • label (:string) (required) - Short caption identifying the metric.
  • value (:any) (required) - Primary metric value to display.
  • icon (:string) - Optional host heroicon class shown by the label. Defaults to nil.
  • subtitle (:string) - Optional muted context below the value. Defaults to nil.
  • href (:string) - Optional LiveView navigation target. Defaults to nil.
  • class (:any) - Extra classes merged onto the card. Defaults to nil.

stat_grid(assigns)

Renders a responsive collection of summary metrics; emits nothing when empty.

Attributes

  • class (:any) - Extra classes merged onto the grid. Defaults to nil.
  • Global attributes are accepted. Arbitrary HTML attributes passed through to the grid.

Slots

  • stat - A summary metric card; provide its value with the :value attribute or inner content. Accepts attributes:
    • label (:string) (required) - Short caption identifying the metric.
    • value (:any) - Primary metric value; inner slot content takes precedence when present.
    • icon (:string) - Optional host heroicon class shown by the label.
    • subtitle (:string) - Optional muted context below the value.
    • href (:string) - Optional LiveView navigation target.
    • class (:any) - Extra classes merged onto this card.