UIPackage
Menu

Framework

Change language

Boilerplate repo

Badge

badgeui

Small inline label for status, counts, or tags — sits beside other content, not as a standalone control. Seven variants: `default`, `secondary`, `destructive`, `outline`, `success`, `warning`, `info`.

Also available for React ->

Installation

$npx shadcn-vue@latest add https://uipkge.dev/r/vue/badge.json
Named registry:npx shadcn-vue@latest add @uipkge/badgeInstalls to:app/components/ui/badge/

Examples

Loading interactive previews…

Props

NameType / ValuesDefaultRequired
variant
'default''secondary''destructive''outline''success''warning''info'
defaultoptional
wrap

Allow the label to wrap onto multiple lines instead of clipping.

booleanoptional
classHTMLAttributes['class']optional
asChildbooleanoptional
asstring | objectoptional

Used by

Files installed (3)

  • app/components/ui/badge/Badge.vue1 kB
    <script setup lang="ts">
    import type { HTMLAttributes } from 'vue'
    import { reactiveOmit } from '@vueuse/core'
    import { Primitive } from 'reka-ui'
    import { cn } from '@/lib/utils'
    import { badgeVariants } from './badge.variants'
    
    // Inlined unions: SFC compiler can't extract runtime props from
    // `BadgeVariants['variant']` or reka-ui's PrimitiveProps.
    const props = withDefaults(
      defineProps<{
        variant?: 'default' | 'secondary' | 'destructive' | 'outline' | 'success' | 'warning' | 'info' | null
        /** Allow the label to wrap onto multiple lines instead of clipping. */
        wrap?: boolean
        class?: HTMLAttributes['class']
        asChild?: boolean
        as?: string | object
      }>(),
      {
        // Match React Badge (`span`) so badges stay valid inside paragraphs/inline text.
        as: 'span',
      },
    )
    
    const delegatedProps = reactiveOmit(props, 'class', 'wrap')
    </script>
    
    <template>
      <Primitive
        data-uipkge
        data-slot="badge"
        :class="cn(badgeVariants({ variant, wrap }), props.class)"
        v-bind="delegatedProps"
      >
        <slot />
      </Primitive>
    </template>
    
  • app/components/ui/badge/badge.variants.ts2.3 kB
  • app/components/ui/badge/index.ts0.3 kB

Raw manifest:https://uipkge.dev/r/vue/badge.json