Skip to content

OrigamCounter ​

<OrigamCounter> is a standalone display-only character counter. It is typically rendered by <OrigamTextField> / <OrigamTextareaField> inside the counter slot, but can be used standalone to show any value/max pair.

Basic usage ​

vue
<template>
  <OrigamCounter :value="42" :max="100" />
</template>

Active / inactive ​

The counter dims when active is false (default) — rendered at --origam-counter---opacity (70% by default) in --origam-counter---color (a muted secondary text colour). It lights up when the parent field is focused: active="true" switches to --origam-counter---opacity-active (100%) in --origam-counter---color-active (the primary action colour). The transition between the two is a plain CSS color, opacity transition — the counter is always present in the DOM and always visible, active never hides it.

vue
<template>
  <OrigamCounter :value="42" :max="100" :active="true" />
  <OrigamCounter :value="42" :max="100" :active="false" />
</template>

Disabled ​

vue
<template>
  <OrigamCounter :value="0" :max="200" disabled />
</template>

Transition ​

The transition prop governs the enter/leave animation played when the <OrigamCounter> element itself is mounted or unmounted by its consumer (e.g. behind a v-if in the parent) — it is unrelated to the active dim/lit state above, which is a plain CSS transition and plays regardless of transition. It defaults to { component: OrigamSlideY } — pass a different transition component descriptor to override it. A bare string (e.g. "fade") sets Vue's native <Transition name="…"> directly, and the DS ships no CSS for that literal name — it silently produces no animation.

vue
<template>
  <OrigamCounter :value="10" :max="50" :active="show" :transition="{ component: OrigamFade }" />
</template>

Density ​

density shifts the rendered font size by a delta of 1px around the --origam-counter---font-size token — the same grammar as <OrigamCard> and <OrigamChip>, where --origam-{component}---density is always a delta, never the value itself.

densityRendered font size
(not passed)token
defaulttoken (strictly identical to not passing the prop)
comfortabletoken + 1px
compacttoken − 1px

Because the delta is added to the token rather than replacing it, a theme that overrides counter.font-size keeps control of the base size at every density.

vue
<template>
  <OrigamCounter :value="42" :max="100" density="compact" />
</template>

The font size is deliberately not animated: transition-property is restricted to paint properties, so a size change lands on the same frame instead of being interpolated over the transition duration.

Slots ​

SlotScopeDescription
default{ counter, max, value }Replaces the rendered text. counter is the already-formatted string ("12" or "12 / 100" when max is set); value and max are the raw props, so a consumer can re-format or add markup. Falls back to when the slot is absent.
vue
<template>
  <OrigamCounter :value="12" :max="100">
    <template #default="{ counter, value, max }">
      <strong :class="{ over: Number(value) > Number(max) }">{{ counter }}</strong>
    </template>
  </OrigamCounter>
</template>

value defaults to 0 via withDefaults, so it is always defined at runtime; max has no default and stays undefined unless passed.

Emits ​

<OrigamCounter> emits no events.

Design tokens ​

CSS variableDefaultDescription
--origam-counter---colorcolor.text.secondaryText color when active is false
--origam-counter---color-activecolor.action.primary.bgText color when active is true
--origam-counter---color-errorcolor.feedback.danger.fgSubtleText color when value > max (origam-counter--error)
--origam-counter---font-size0.625rem (font.size.xs)Base font size, before the density delta
--origam-counter---font-weightfont.weight.regularFont weight
--origam-counter---letter-spacingfont.letterSpacing.normalLetter spacing
--origam-counter---padding-inlinespace.1Inline padding
--origam-counter---opacity70%Opacity when active is false
--origam-counter---opacity-active100%Opacity when active is true
--origam-counter---density0pxDensity delta added to the base font size (component-local, not a theme token)
--origam-counter---transition-duration100ms (motion.duration.fast)Duration of the colour / opacity transition