Skip to content

useBadge ​

Determines whether an action button should show a badge and returns the badge props to spread onto <v-badge>.

File: vue/src/js/hooks/utils/useBadge.js


Usage ​

js
import useBadge from '@/hooks/utils/useBadge'

const { isBadge, badgeProps } = useBadge(props, context)
html
<v-badge v-if="isBadge(action)" v-bind="badgeProps(action)">
  <v-icon>{{ action.icon }}</v-icon>
</v-badge>

Returns ​

NameSignatureDescription
isBadge(action: Object) => BooleanReturns true when the action has a badge property with a truthy / non-zero value
badgeProps(action: Object) => ObjectReturns { content, color, textColor } ready to spread onto <v-badge>

Badge Action Fields ​

FieldTypeDescription
badgeBoolean|Number|StringBadge visibility / content. Numeric strings are parsed — '0' hides the badge.
badgeContentanyBadge label (falls back to badge if not set)
badgeColorStringBadge background color (default 'warning')
badgeTextColorStringBadge text color (default 'white')

See Also ​