Counter
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.
<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
tagprop (default:div). Wrapped in<origam-transition>for animated show/hide. Modifier--errorapplied whenvalue > 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.
- activeboolean
- Controls visibility via the slide-y transition. When false the counter collapses animated.
- disabledbooleanfalse
- Reduces opacity and suppresses the error colour when the field is disabled.
- maxstring | number
- Maximum character count. When value exceeds max the counter switches to the error colour.
- valuestring | number
- Current character count (or the value string, length is derived if needed).
- idstring
- classstring | Array<string> | object
- stylestring | Array<string> | object | StyleValue
- tagstring'div'
- HTML element rendered at the root. Defaults to div.
- paddingboolean | number | string
- paddingTopboolean | number | string
- paddingLeftboolean | number | string
- paddingBottomboolean | number | string
- paddingRightboolean | number | string
- paddingBlockboolean | number | string
- paddingInlineboolean | number | string
- Inline (left/right) padding of the counter badge.
- paddingInlineStartboolean | number | string
- paddingInlineEndboolean | number | string
- paddingBlockStartboolean | number | string
- paddingBlockEndboolean | number | string
- marginboolean | number | string
- marginTopboolean | number | string
- marginLeftboolean | number | string
- marginBottomboolean | number | string
- marginRightboolean | number | string
- marginBlockboolean | number | string
- marginInlineboolean | number | string
- marginInlineStartboolean | number | string
- marginInlineEndboolean | number | string
- marginBlockStartboolean | number | string
- marginBlockEndboolean | number | string
- borderboolean | number | string | TDirectionBoth | Array<TDirectionBoth>false
- Applies a border around the counter badge.
- borderTopboolean | number | string
- borderLeftboolean | number | string
- borderBottomboolean | number | string
- borderRightboolean | number | string
- borderBlockboolean | number | string
- borderInlineboolean | number | string
- borderInlineStartboolean | number | string
- borderInlineEndboolean | number | string
- borderBlockStartboolean | number | string
- borderBlockEndboolean | number | string
- borderColorstring
- borderStylestring
- borderTopColorTColor
- borderRightColorTColor
- borderBottomColorTColor
- borderLeftColorTColor
- borderInlineStartColorTColor
- borderInlineEndColorTColor
- borderBlockStartColorTColor
- borderBlockEndColorTColor
- Border-radius token applied to the counter badge.
- roundedTopRightboolean | number | string
- roundedTopLeftboolean | number | string
- roundedBottomLeftboolean | number | string
- roundedBottomRightboolean | number | string
- roundedStartStartboolean | number | string
- roundedStartEndboolean | number | string
- roundedEndStartboolean | number | string
- roundedEndEndboolean | number | string
- color
- Intent or custom colour for the counter text.
- bgColorTColor
- elevationTElevation
- Box-shadow elevation applied to the counter badge.
- Density adjustment passed through to the root element.
- transitionboolean | 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.
- colorvar(--origam-color__text---secondary)
- Default text colour.
- colorvar(--origam-color__action--primary---bg)
- Text colour when field is active/focused.
- colorvar(--origam-color__feedback--danger---fgSubtle)
- Text colour when value exceeds max.
- dimensionvar(--origam-font__size---xs)
- Counter font size.
- numbervar(--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
Over-limit state
Embedded in TextField