Skip to content

Badge バッジ ​

アイコン右上のコーナーバッジで、通知数、状態ドット、カスタム文言に使います。

基本的な使い方 ​

vue
<template>
  <lh-badge :value="8">
    <lh-button size="small">メッセージ</lh-button>
  </lh-badge>
  <lh-badge :value="8" type="primary">
    <lh-button size="small">プライマリ</lh-button>
  </lh-badge>
</template>

数値の扱い ​

vue
<template>
  <lh-badge :value="200" :max="99">
    <lh-button size="small">max 超えは 99+ を表示</lh-button>
  </lh-badge>
  <lh-badge :value="0" show-zero>
    <lh-button size="small">0 を表示</lh-button>
  </lh-badge>
  <lh-badge :value="0">
    <lh-button size="small">0 を非表示</lh-button>
  </lh-badge>
  <lh-badge content="新">
    <lh-button size="small">カスタム文言</lh-button>
  </lh-badge>
</template>

小さいドット ​

vue
<template>
  <lh-badge is-dot>
    <lh-button size="small">新着メッセージあり</lh-button>
  </lh-badge>
</template>

オフセットとサイズ ​

vue
<template>
  <lh-badge :value="8" :offset="[6, 4]">
    <lh-button size="small">オフセット</lh-button>
  </lh-badge>
  <lh-badge :value="8" size="small">
    <lh-button size="small">小サイズ</lh-button>
  </lh-badge>
</template>

Props ​

プロパティ説明型デフォルト値
typeタイプ'primary' | 'success' | 'warning' | 'danger' | 'info' | 'default''danger'
value表示する数値string | number—
sizeサイズ'small' | 'medium' | 'large''medium'
max最大値。超えた場合は ${max}+ を表示number99
isDot小さいドットか(数値を表示しない)booleanfalse
hidden非表示にするかbooleanfalse
offsetデフォルト位置からのオフセット [x, y]。負の margin で実現[number, number]—
showZerovalue が 0 のときに表示するかbooleanfalse
contentカスタム文言(value より優先)string—
customClassカスタムクラス名string—
sxクイックレイアウトプロパティLhSxProps—

Slots ​

スロット説明
defaultバッジが付く対象のコンテンツ

Vue3 版との差異

進退アニメーションは Vue 内蔵の <transition> に依存せず(ミニプログラムのトランジション終了イベントは信頼できないため)、class の切り替え + タイマーで 0.15s のアニメーション時間に合わせます。見た目の表現は plus と同じです。