# Progress プログレスバー

タスクの進捗を可視化します。ライン型とサークル型の二つの形状を備え、ステータス配色、カスタムカラー関数、テキストのフォーマットをサポートします。

プログレスバー
<template>
  <div class="demo-col">
    <p class="demo-note">line ライン型</p>
    <LhProgress :percentage="30" />
    <LhProgress :percentage="70" status="success" />
    <LhProgress :percentage="45" status="warning" />
    <LhProgress :percentage="20" status="danger" />
    <LhProgress :percentage="60" :stroke-width="20" :format="fmt" />
    <LhProgress :percentage="100" :show-text="false" />
    <p class="demo-note">circle サークル型(width がキャンバスサイズ、strokeWidth が線の太さを制御)</p>
    <div class="demo-row" style="gap: 32px; flex-wrap: wrap">
      <LhProgress type="circle" :percentage="75" />
      <LhProgress type="circle" :percentage="40" :width="120" :stroke-width="14" status="warning" />
      <LhProgress type="circle" :percentage="100" status="success" :format="fmt" />
    </div>
    <p class="demo-note">color は文字列またはパーセンテージに基づいて色を返す関数</p>
    <LhProgress :percentage="percent" :color="colorFn" />
    <LhButton size="small" @click="bump">{{ percent >= 100 ? 'リセット' : '+10' }}</LhButton>
  </div>
</template>

<script>
export default {
  data: () => ({
    percent: 30,
  }),
  methods: {
    fmt(p) {
      return `${p / 10} 割`
    },
    colorFn(p) {
      if (p < 40) return 'var(--lh-danger-color)'
      if (p < 80) return 'var(--lh-warning-color)'
      return 'var(--lh-success-color)'
    },
    bump() {
      this.percent = this.percent >= 100 ? 0 : this.percent + 10
    },
  },
}
</script>

# Props

プロパティ 説明 型 デフォルト値
percentage 進捗のパーセンテージ 0-100(範囲を超えると自動的にクランプ) number —
type タイプ 'line' \| 'circle' 'line'
status ステータス 配色 'default' \| 'success' \| 'warning' \| 'danger' 'default'
color プログレスバーの色:文字列またはパーセンテージに基づいて色を返す関数 string \| ((percentage: number) => string) —
strokeWidth 線の太さ px(line では高さ、circle では線の太さ) number —
width サークルモードのキャンバス幅 px number —
showText 進捗テキストを表示するかどうか boolean true
format テキストのカスタムフォーマット (percentage: number) => string —
sx sx によるレイアウト省略記法 — —

Copyright © 2024-2026 FengMo WenXue