vael-ui v0.5.7

Data display

Layout

Badge

A small dot, count or label for status or something new. Use it in the badge slot of a Button or an Avatar to pin it to a corner.

Install

import { Badge } from 'vael-ui'

Playground

5
Usage
<script setup lang="ts">
import { Badge } from 'vael-ui'
</script>

<template>
  <Badge :count="5" />
</template>

Props

NameTypeDefaultDescription
variant'primary' | 'danger' | 'muted' | 'success' | 'warning' | 'info''primary'Color variant.
countnumberNumber to display; capped by max.
maxnumber99Counts above this render as "${max}+".
dotbooleanfalseMinimal size with no content: a plain presence dot.
animatedbooleantruefalse drops the built-in count-change animation so you can drive your own.
motionBadgeMotionHow it moves: its appearance ({ initial: { root: { opacity: 0, scale: 0.6 } } }). false turns all of its motion off, the count change included.
uiPartial<Record<'root', UiPartValue>>Class and style overrides for each part.

Events

No events.

Slots

NameTypeDescription
defaultanyOverrides count entirely; anything you render here wins.

Exposed

NameTypeDescription
elHTMLElement | nullRoot element.
partsRecord<string, HTMLElement | HTMLElement[] | null>Its elements by part name, for your own animation; a repeated part is an array.

Motion New

Badge: its appearance.

<Badge
  :motion="{ initial: { root: { opacity: 0, y: 4 } } }"
/>
NameTypeDescription
initialexitrootSets where each part comes in from and leaves to: any CSS property, plus x, y and blur. A plain number is px, or degrees for rotate.
enterleave(parts, context) => animationAnimates the parts with GSAP, motion or element.animate(). Return the animation and the component waits for it, and stops it if interrupted.
springdurationeasing{ damping, response } | number | stringTimes all of it: a spring, or a duration in ms with an easing. Never both.
falsebooleanTurns its motion off, for an animation of your own on its exposed elements.

Accessibility

It has no keyboard interaction of its own.

  • Badge is a <span> with no role, and screen readers read its count as plain text, such as “99+”.
  • A dot badge renders no text. Say what it means in nearby text.
  • It has no live region, so count changes are not announced.