Counter

Data Display
stable

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

Structure

Anatomie

Décomposition visuelle de la structure interne du composant avec les appels de classes BEM.

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

Toutes les props acceptées par ce composant, avec leur type, valeur par défaut et 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

Emplacements de contenu exposés par ce composant.

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

API

Membres exposés

Propriétés et méthodes accessibles via ref template (defineExpose). Utilisés pour le contrôle programmatique.

<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.

Personnalisation

Variables CSS

Propriétés CSS personnalisées exposées par ce composant. Surchargez-les pour personnaliser sans perdre la compatibilité avec le thème.

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

Accessibilité

Rôles ARIA, navigation clavier et gestion du focus. Sourcé depuis le template réel du composant.

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.

Fondation

Design tokens

Extrait des tokens de ce composant — les variables --origam-<composant>---<propriété>, déclarées dans sa feuille de tokens tenue à la main, sans étape de build.

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.

Interactif

Playground

Modifiez les props en direct et observez le composant se mettre à jour. Le snippet de code généré suit vos changements.

Rendu de l’aperçu en cours…

Usage

Exemples

Extraits de code prêts à coller dans vos templates.

Character counter

vue

Over-limit state

vue

Embedded in TextField

vue