Badge

Data Display
stable

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

Preview

Rendering the live preview…

count

Rendering the live preview…

dot

Rendering the live preview…

max

Rendering the live preview…

floating

Structure

Anatomy

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

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

All props accepted by this component, with their type, default value and 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

Content slots exposed by this component.

#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

Events emitted by this component.

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

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

Customisation

CSS variables

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

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

Accessibility

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

ARIA roles

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.

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

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.

Count badges

vue

Locations

vue

Inline badge

vue