Workflow state
Show whether a review is pending, approved, or blocked beside its title.
Components / Display
A compact status or category label.
Last changed in version 0.13.0: Add avatar groups and chips, expand the block gallery, and improve component colors, spacing, and motion.
bunx --bun @getweini/cli@latest add badgeImport the files copied by the install command, then place the component in your Vue template. The text and values in the example belong to your app; change them to fit your task.
<script setup lang="ts">
import Badge from './components/ui/badge/Badge.vue'
</script>
<template>
<Badge>New</Badge>
<Badge variant="secondary" aria-label="Draft, 3 items">
Draft
<template #suffix><span aria-hidden="true">3</span></template>
</Badge>
<Badge variant="success">
<template #prefix>
<span aria-hidden="true" class="size-1.5 rounded-full bg-current" />
</template>
Live
</Badge>
<Badge variant="warning">Pending</Badge>
<Badge variant="destructive">Blocked</Badge>
<Badge variant="outline">Preview</Badge>
</template>Add text or decorative icons with the prefix and suffix slots. Each slot also has a data-slot attribute for custom styling.
Show whether a review is pending, approved, or blocked beside its title.
Pair a category label with a count in a table cell or list row.
Use a word as well as color to communicate the state.
<script setup lang="ts">
import Badge from './components/ui/badge/Badge.vue'
</script>
<template>
<p>Change request <Badge variant="warning">Awaiting review</Badge></p>
</template>A suffix can hold a decorative count when the accessible name carries the full meaning.
<script setup lang="ts">
import Badge from './components/ui/badge/Badge.vue'
</script>
<template>
<Badge variant="secondary" aria-label="3 unread messages">
Unread <template #suffix><span aria-hidden="true">3</span></template>
</Badge>
</template>Every public prop, model, event, slot, and exposed member of the installed Vue parts is listed below. “Not set” means you can leave that value out; “Required” means you must provide it. Native HTML attributes also work where the component uses a native element.
| Name | Type or signature | Default | What it does |
|---|---|---|---|
variantprop | "default" | "success" | "warning" | "destructive" | "secondary" | "outline" | undefined | "default" | Choose the visual treatment for this component. |
defaultslot | () => unknown | Required | Content shown inside Badge. |
prefixslot | (() => unknown) | undefined | Optional | Content shown before the main label or value. |
suffixslot | (() => unknown) | undefined | Optional | Content shown after the main label or value. |
// packages/frameworks/vue/components/badge/types.ts
import type { badgeVariants } from './styles'
// ------- TYPES -------
export interface BadgeProps {
variant?: keyof typeof badgeVariants
}
// packages/frameworks/vue/components/badge/styles.ts
// Add or change a Badge color here; the public variant type follows these keys.
export const badgeVariants = {
default: 'border-transparent bg-primary text-primary-foreground',
secondary: 'border-transparent bg-secondary text-secondary-foreground',
outline: 'border-border text-foreground',
success: 'border-transparent bg-success text-success-foreground',
warning: 'border-transparent bg-warning text-warning-foreground',
destructive: 'border-transparent bg-destructive text-destructive-foreground',
} as const