Badge

Data Display
stable

Overlay badge for notification counts, status dots and labels, anchored to a wrapped element.

Aperçu

Rendu de l’aperçu en cours…

count

Rendu de l’aperçu en cours…

dot

Rendu de l’aperçu en cours…

max

Rendu de l’aperçu en cours…

floating

Structure

Anatomie

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

Anatomy of OrigamBadgeSchematic of the Badge component with 3 numbered internal parts. #default slot (anchor element) 42 1 2 3 Badge pill uses OrigamTransition (fade by default) for show/hide
Anatomy of <origam-badge> — 3 parts: root ①, relative wrapper ②, and the absolute-positioned badge pill ③.
1.origam-badge
Root element (display: inline-flex). Receives the tag prop (default <div>). Modifiers: --dot, --floating, --inline.
2.origam-badge__wrapper
Relative-positioned container that anchors the badge pill. Contains the #default slot (the host element).
3.origam-badge__badge
The visible badge pill (position: absolute). Location computed by useLocation. Content capped at max. Wrapped in OrigamTransition for show/hide animation. Has role="status", aria-live="polite", aria-atomic="true".

API

Props

Toutes les props acceptées par ce composant, avec leur type, valeur par défaut et description.

content
number | string
Text or number displayed inside the badge. Use max to cap large numbers.
dot
boolean
false
Renders as a small dot without content — useful for status indicators.
floating
boolean
false
Floats the badge at the corner of the wrapped element with reduced offset.
inline
boolean
false
Renders the badge inline instead of as a positioned overlay.
label
string
'origam.badge'
Accessible aria-label for the badge element.
max
number | string
Maximum value to display. When content exceeds max, renders "max+" instead.
modelValue
boolean
true
Controls the badge visibility. Use v-model to bind two-way.
offsetX
number | string
Horizontal offset from the anchor corner (CSS length or number in px).
offsetY
number | string
Vertical offset from the anchor corner (CSS length or number in px).
id
string
class
string | Array<string> | object
style
string | Array<string> | object | StyleValue
tag
string
'div'
HTML element rendered at the root wrapper.
border
boolean | number | string | TDirectionBoth | Array<TDirectionBoth>
false
Applies a 2px border ring around the badge (useful for contrast against the background).
borderTop
boolean | number | string
disabled
boolean
false
Hides the badge overlay when true.
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
color
Intent or custom foreground color applied to the badge.
bgColor
Badge background color.
location
TAnchor
'top end'
Corner of the host element where the badge is anchored.
Border-radius token for the badge pill. Default is {radius.full}.
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
transition
boolean | string | TTransitionProps
OrigamFade
Transition applied when the badge appears/disappears. Defaults to fade.
status
TStatus
statusIconPosition
TStatusPosition
icon
TIcon
hover
boolean | IStateEffectConfig
hoverClass
string
elevation
TElevation
Box-shadow elevation token for the badge.
fontSize
TFontSize
fontWeight
TFontWeight
appendAvatar
string
appendIcon
TIcon
prependAvatar
string
prependIcon
TIcon
prependAriaLabel
string
appendAriaLabel
string

API

Slots

Emplacements de contenu exposés par ce composant.

#default
The element the badge is anchored to. Wrapped in a relative-positioned container.
#badge
Custom content rendered inside the badge pill, replacing the content prop.
#prepend
Icon or content before the badge text.
#append
Icon or content after the badge text.

API

Emits

Événements émis par ce composant.

@click:append
MouseEvent
@click:prepend
MouseEvent
@update:hover
boolean

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 to a child component.
Ref<string>
Reactive CSS string generated by useStyle from the computed badgeContentStyles.
string
Unique style-sheet ID for this instance.
() => void
Injects the computed style sheet. Called automatically on mount.
() => void
Removes the injected style sheet. Called automatically on unmount.
Ref<boolean>
True once the style sheet has been injected into the DOM.

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.

Badge pill background. Overridden by color/bgColor prop and status.
Badge pill foreground color.
Pill border radius. Default is full circle; overridden by rounded prop.
Badge pill height. Fixed at 20px (1.25rem). Shrinks to 9px in dot mode.
Minimum badge width for circular single-digit display.
Badge content font size.
Badge content font weight.
Transition duration for badge position/opacity animations.

Inclusion

Accessibilité

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

Rôles ARIA

status

Notes

  • The badge pill has role="status" with aria-live="polite" and aria-atomic="true". Screen readers announce badge content changes (e.g. new count).
  • The label prop (or the translated "origam.badge" key) is used as aria-label to describe the badge to screen readers. Pass a meaningful value like "5 unread notifications".
  • In dot mode, the content is visually hidden (text-indent: -9999px) but the aria-label still conveys the status to screen readers.

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__action--primary---bg)
Default badge pill background.
dimension
var(--origam-radius---full)
Full-circle border radius by default.
dimension
1.25rem
Badge pill height (20px).
dimension
var(--origam-font__size---sm)
Badge content font size.
color
var(--origam-color__feedback--danger---bg)
Background for error/danger status badges.
duration
225ms
Badge position/opacity transition duration.

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.

Count badges

vue

Locations

vue

Inline badge

vue