Badge
VBadge displays a count, icon or status dot, alone or attached to another element.
Usage
vue
8
Examples
Variants
variant selects solid or soft. Dots are always solid.
vue
8888
Tones
tone sets the semantic colour.
vue
88888
Custom colours
color overrides the tone with a CSS colour.
vue
8888
Counters
Counts above 99 appear as 99+.
vue
34299+
With an icon
icon takes precedence over count.
vue
Dot
dot shows a status dot and ignores count and icon content.
vue
Inline
The default slot provides the target. Include the badge information in that target’s accessible name.
vue
MessagesDeployment
Overlay
overlay places the badge at the target’s corner.
vue
Overlay position
overlayPosition chooses the top or bottom corner. The horizontal side follows the reading direction.
vue
Bordered
bordered adds a ring. Set ringColor to match the target’s surface.
vue
API
Props
| Prop | Type | Default |
|---|---|---|
variant | BadgeVariant'solid' | 'soft' | 'solid' |
| Visual style. | ||
tone | BadgeTone'neutral' | 'accent' | 'danger' | 'success' | 'warning' | 'accent' |
| Colour tone. | ||
color | string | none |
Custom CSS colour. For solid badges, check foreground contrast in browsers without contrast-color() support. | ||
count | number | none |
Count to display. Values above 99 appear as 99+. | ||
icon | IconSource | none |
| Icon replacing the count. | ||
dot | boolean | false |
| Shows a status dot without content. | ||
overlay | boolean | false |
| Places the badge at the target’s corner. Requires a target in the default slot. | ||
overlayPosition | BadgeOverlayPosition'top' | 'bottom' | 'top' |
| Top or bottom corner. The horizontal side follows the reading direction. | ||
bordered | boolean | false |
| Adds a ring around the badge. | ||
ringColor | string | none |
| Ring colour when bordered. Defaults to the page background. | ||
Slots
| Slot | Type |
|---|---|
default | {} |
| Target element. Attached badges are hidden from assistive technology; include their information in the target’s accessible name. | |
Types
Types used in the API tables. Import exported types from vectis-ui.
export interface BuiltinIcon {
name: string
paths: readonly [string] | readonly [string, string]
}export type IconRender =
| { path: string; viewBox?: string }
| { component: Component; props?: Record<string, unknown> }
| { src: string }
| { text: string; class?: string }
| { class: string }export type IconSource = string | BuiltinIcon | IconRender
CSS variables
| Token | Value |
|---|---|
--vectis-control-size-badge-h | 1.25rem |
--vectis-control-size-badge-dot | 0.625rem |
--vectis-control-size-badge-ring | 2px |