Liking cljdoc? Tell your friends :D

x-stat

A themeable, accessible metric display component for presenting a label, value, and contextual hint. Supports semantic variants, size/emphasis/alignment options, trend indication, named slots, and a loading state.


Tag

<x-stat></x-stat>

Attributes

AttributeTypeDefaultDescription
variantenum"default"Semantic variant: default subtle positive warning danger
alignenum"start"Text alignment: start center end
sizeenum"md"Display size: sm md lg
emphasisenum"normal"Value emphasis: normal high
trendenum"neutral"Trend direction: up down neutral
loadingbooleanfalseShows loading state with reduced opacity
labelstringMetric label text
valuestringMetric value text
hintstringSupplementary hint text

Properties

PropertyTypeReflects attribute
variantstringvariant
alignstringalign
sizestringsize
emphasisstringemphasis
trendstringtrend
loadingbooleanloading
labelstringlabel
valuestringvalue
hintstringhint

Events

None. This component is a pure display element.


Slots

SlotDescription
iconCustom icon element
labelCustom label content (overrides label attribute text)
valueCustom value content (overrides value attribute text)
hintCustom hint content (overrides hint attribute text)
(default)Additional content appended to the body
<x-stat variant="positive" trend="up">
  <span slot="icon" aria-hidden="true">↗</span>
  <span slot="label">Monthly recurring revenue</span>
  <span slot="value">$84,920</span>
  <span slot="hint">Up 11.4% from last month</span>
</x-stat>

Parts

PartDescription
baseOuter grid wrapper
iconIcon area containing the icon slot
bodyBody area containing label, value, hint, and default slot
labelLabel row (contains label slot + text span)
valueValue row (contains value slot + text span)
hintHint row (contains hint slot + text span)

CSS Custom Properties

Layout

VariableDefaultDescription
--x-stat-backgroundtransparentBackground colour
--x-stat-colorinheritBase text colour
--x-stat-muted-colorrgba(0,0,0,0.55)Muted text colour (label, hint)
--x-stat-border-colortransparentBorder colour
--x-stat-radius12pxBorder radius
--x-stat-padding16pxPadding
--x-stat-gap6pxGrid gap

Typography

VariableDefaultDescription
--x-stat-label-colormuted-colorLabel text colour
--x-stat-label-size12pxLabel font size
--x-stat-value-colorcolorValue text colour
--x-stat-value-size20pxValue font size
--x-stat-hint-colormuted-colorHint text colour
--x-stat-hint-size12pxHint font size
--x-stat-icon-colorcolorIcon colour

Semantic colour tokens

VariableDefault (light)Description
--x-stat-positive-color#16a34aPositive variant value colour
--x-stat-warning-color#d97706Warning variant value colour
--x-stat-danger-color#dc2626Danger variant value colour

Dark-mode variants are set automatically via @media (prefers-color-scheme: dark).

Motion & state

VariableDefaultDescription
--x-stat-transition-duration120msTransition duration
--x-stat-transition-timingeaseTransition easing function
--x-stat-loading-opacity0.6Opacity when loading

Accessibility

  • Host element carries role="figure".
  • When loading is set, aria-busy="true" is applied.
  • aria-label is derived from the label attribute.
  • Animations respect @media (prefers-reduced-motion: reduce).

Examples

Basic usage

<x-stat label="Revenue" value="$128.4K" hint="Quarter to date"></x-stat>

Semantic variants

<x-stat variant="positive" label="Growth" value="+18.2%" hint="Healthy trend"></x-stat>
<x-stat variant="warning" label="At-risk" value="12" hint="Review recommended"></x-stat>
<x-stat variant="danger" label="Failed" value="3" hint="Action required"></x-stat>

Size and emphasis

<x-stat size="sm" label="Compact" value="128"></x-stat>
<x-stat size="lg" emphasis="high" align="center" label="Headline" value="$2.4M"></x-stat>

Loading state

<x-stat loading label="Forecast" value="Loading…" hint="Refreshing"></x-stat>

Rich content via slots

<x-stat variant="positive" trend="up">
  <span slot="icon" aria-hidden="true">↗</span>
  <span slot="label">Monthly recurring revenue</span>
  <span slot="value">$84,920</span>
  <span slot="hint">Up 11.4% from last month</span>
</x-stat>

ClojureScript (hiccup renderer)

[:x-stat {:variant "positive"
          :label   "Net growth"
          :value   "+18.2%"
          :hint    "Healthy upward trend"}]

Can you improve this documentation?Edit on GitHub

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close