Skip to content

Badge ​

Floating badge indicator that wraps around content to display counts, dots, or status.

12
3
1
2
1
vue
<script setup lang="ts">
import { VxBadge } from 'veloxui'
</script>

<template>
  <VxBadge :value="12">
    <button>comments</button>
  </VxBadge>
  <VxBadge :value="3">
    <button>replies</button>
  </VxBadge>
  <VxBadge :value="1" type="primary">
    <button>messages</button>
  </VxBadge>
</template>

Max Value ​

When the count exceeds max, it shows as max+. Default max is 99.

8
99+
999+
vue
<template>
  <VxBadge :value="8" :max="10">
    <button>comments</button>
  </VxBadge>
  <VxBadge :value="100" :max="99">
    <button>replies</button>
  </VxBadge>
  <VxBadge :value="1000" :max="999">
    <button>notifications</button>
  </VxBadge>
</template>

Types ​

5
5
5
5
5
vue
<template>
  <VxBadge :value="5" type="danger">...</VxBadge>
  <VxBadge :value="5" type="primary">...</VxBadge>
  <VxBadge :value="5" type="success">...</VxBadge>
  <VxBadge :value="5" type="warning">...</VxBadge>
  <VxBadge :value="5" type="info">...</VxBadge>
</template>

Custom Color ​

1
2
3
vue
<template>
  <VxBadge :value="1" color="#8b5cf6">
    <button>Purple</button>
  </VxBadge>
</template>

Dot ​

Show a small dot indicator instead of a number.

vue
<template>
  <VxBadge dot>
    <button>messages</button>
  </VxBadge>
  <VxBadge dot type="success">
    <button>status</button>
  </VxBadge>
</template>

Text Value ​

Use string values for non-numeric badges.

new
hot
vue
<template>
  <VxBadge value="new" type="success">
    <button>Features</button>
  </VxBadge>
  <VxBadge value="hot" color="#ef4444">
    <button>Deals</button>
  </VxBadge>
</template>

Offset ​

Adjust badge position with offset as [top, right] in pixels.

8
8
vue
<template>
  <VxBadge :value="8" :offset="[5, 5]">
    <button>Adjusted</button>
  </VxBadge>
</template>

Show Zero ​

By default, a value of 0 hides the badge. Use show-zero to show it.

0
vue
<template>
  <VxBadge :value="0">
    <button>Hidden</button>         <!-- badge hidden -->
  </VxBadge>
  <VxBadge :value="0" show-zero>
    <button>Shown</button>          <!-- shows "0" -->
  </VxBadge>
</template>

Hidden ​

Dynamically hide/show the badge.

12
count: 12
vue
<script setup lang="ts">
import { ref } from 'vue'

const count = ref(12)
</script>

<template>
  <VxBadge :value="count" :hidden="count === 0">
    <button>notifications</button>
  </VxBadge>
  <button @click="count++">+</button>
  <button @click="count = Math.max(0, count - 1)">-</button>
</template>

Standalone ​

Without slot content, the badge renders inline.

5
42
vue
<template>
  <VxBadge :value="5" />
  <VxBadge :value="42" type="primary" />
  <VxBadge dot type="success" />
</template>

Props ​

PropTypeDefaultDescription
valuestring | number—Badge content (number or text)
maxnumber99Max number before showing max+
dotbooleanfalseShow dot instead of number
hiddenbooleanfalseHide the badge
type'danger' | 'primary' | 'success' | 'warning' | 'info''danger'Color preset
colorstring''Custom background color
offset[number, number]—Position offset [top, right] in pixels
showZerobooleanfalseShow badge when value is 0

Slots ​

SlotDescription
defaultContent to wrap (button, icon, avatar, etc.)