Counter

Data Display
stable

Animated character-count badge that shows current/max values. Used internally by TextField, Textarea and similar inputs.

Structure

Anatomy

Visual breakdown of the component's internal structure with BEM class call-outs.

Anatomy of OrigamCounterSchematic of the Counter component with numbered parts. 12 / 50 1 2 origam-counter (root tag) #default slot — renders "value / max" Wrapped in OrigamTransition (slide-y). --error modifier when value > max.
Anatomy of <origam-counter>. A single root element (① tag) wraps the default slot (②) which renders the computed "value / max" string. The --error modifier is applied when value > max.
1.origam-counter
Root element. Tag is controlled by the tag prop (default: div). Wrapped in <origam-transition> for animated show/hide. Modifier --error applied when value > max.
2#default slot
Counter content. Default renderer produces "value / max" when max is set, or just "value" otherwise. Slot props: { counter, max, value }.

API

Props

All props accepted by this component, with their type, default value and description.

active
boolean
Controls visibility via the slide-y transition. When false the counter collapses animated.
disabled
boolean
false
Reduces opacity and suppresses the error colour when the field is disabled.
max
string | number
Maximum character count. When value exceeds max the counter switches to the error colour.
value
string | number
Current character count (or the value string, length is derived if needed).
id
string
class
string | Array<string> | object
style
string | Array<string> | object | StyleValue
tag
string
'div'
HTML element rendered at the root. Defaults to div.
padding
boolean | number | string
paddingTop
boolean | number | string
paddingLeft
boolean | number | string
paddingBottom
boolean | number | string
paddingRight
boolean | number | string
paddingBlock
boolean | number | string
paddingInline
boolean | number | string
Inline (left/right) padding of the counter badge.
paddingInlineStart
boolean | number | string
paddingInlineEnd
boolean | number | string
paddingBlockStart
boolean | number | string
paddingBlockEnd
boolean | number | string
margin
boolean | number | string
marginTop
boolean | number | string
marginLeft
boolean | number | string
marginBottom
boolean | number | string
marginRight
boolean | number | string
marginBlock
boolean | number | string
marginInline
boolean | number | string
marginInlineStart
boolean | number | string
marginInlineEnd
boolean | number | string
marginBlockStart
boolean | number | string
marginBlockEnd
boolean | number | string
border
boolean | number | string | TDirectionBoth | Array<TDirectionBoth>
false
Applies a border around the counter badge.
borderTop
boolean | number | string
borderLeft
boolean | number | string
borderBottom
boolean | number | string
borderRight
boolean | number | string
borderBlock
boolean | number | string
borderInline
boolean | number | string
borderInlineStart
boolean | number | string
borderInlineEnd
boolean | number | string
borderBlockStart
boolean | number | string
borderBlockEnd
boolean | number | string
borderColor
string
borderStyle
string
borderTopColor
TColor
borderRightColor
TColor
borderBottomColor
TColor
borderLeftColor
TColor
borderInlineStartColor
TColor
borderInlineEndColor
TColor
borderBlockStartColor
TColor
borderBlockEndColor
TColor
Border-radius token applied to the counter badge.
roundedTopRight
boolean | number | string
roundedTopLeft
boolean | number | string
roundedBottomLeft
boolean | number | string
roundedBottomRight
boolean | number | string
roundedStartStart
boolean | number | string
roundedStartEnd
boolean | number | string
roundedEndStart
boolean | number | string
roundedEndEnd
boolean | number | string
color
Intent or custom colour for the counter text.
bgColor
TColor
elevation
TElevation
Box-shadow elevation applied to the counter badge.
density
'default'
Density adjustment passed through to the root element.
transition
boolean | string | TTransitionProps
'origam-slide-y-transition'
Animation transition when the counter appears / disappears. Defaults to slide-y.

API

Slots

Content slots exposed by this component.

#default
Custom counter content. By default renders the computed "value / max" or "value" string.

API

Exposed members

Properties and methods accessible via template ref (defineExpose). Use them for programmatic control.

<T extends object>(props: T, exclude?: string[]) => Partial<T>
Utility to forward a filtered subset of props.
Ref<string>
Reactive CSS string for the injected style sheet.
string
Unique style-sheet ID for this instance.
() => void
Injects the style sheet into the document.
() => void
Removes the style sheet from the document.
Ref<boolean>
True once the style sheet has been injected.

Customisation

CSS variables

CSS custom properties exposed by this component. Override them to customise the component without losing theme compatibility.

Default counter text colour.
Counter text colour when the field is focused / active.
Counter text colour when value exceeds max (--error modifier).
Counter font size.
Counter font weight.
Default opacity. Set to 1 when active/focused.
Transition duration for colour/opacity changes.

Inclusion

Accessibility

ARIA roles, keyboard navigation and focus management. Sourced from the real component template.

Notes

  • OrigamCounter is a visual helper only. When embedded in a text field, the parent field should use aria-describedby pointing to the counter element so screen readers announce the character count.
  • For dynamic character-count announcements, add aria-live="polite" to the counter element or its parent container.

Foundation

Design tokens

Excerpt from this component's token declarations — the --origam-<component>---<property> variables, declared in its hand-maintained token sheet with no build step.

Source
color
var(--origam-color__text---secondary)
Default text colour.
color
var(--origam-color__action--primary---bg)
Text colour when field is active/focused.
color
var(--origam-color__feedback--danger---fgSubtle)
Text colour when value exceeds max.
dimension
var(--origam-font__size---xs)
Counter font size.
number
var(--origam-opacity---70)
Default counter opacity.

Interactive

Playground

Edit props live and see the component update in real time. The generated code snippet updates as you change values.

Rendering the live preview…

Usage

Examples

Ready-to-paste code snippets for your templates.

Character counter

vue

Over-limit state

vue

Embedded in TextField

vue