Progress プログレスバー
タスクや容量の達成状況を示します。線形と円形の 2 つの形態をサポートし、色とテキストはカスタマイズ可能です。
基本的な使い方
基本的な使い方
60%
100%
80%
40%
55%
70 ポイント
75%
100%
30%
import { LhProgress } from '@lh-ui/react'
export default function Demo() {
return (
<>
<LhProgress percentage={60} />
<LhProgress percentage={80} status="warning" />
<LhProgress type="circle" percentage={75} />
</>
)
}
Progress Props
| Prop | 説明 | 型 | 指定可能値 | デフォルト |
|---|---|---|---|---|
| percentage | 進度パーセンテージ。[0, 100] を超えると自動的にクランプ | number | — | 0 |
| type | 形態 | 'line' | 'circle' | — | 'line' |
| status | ステータス。normal の場合 100 に達すると自動的に success になる | 'normal' | 'success' | 'warning' | 'exception' | — | 'normal' |
| color | 進行バーの色:文字列またはパーセンテージに応じて色を返す関数 | string | ((percentage: number) => string) | — | — |
| strokeWidth | 線の太さ px(line は高さ、circle はストロークの太さ) | number | — | 6 |
| width | 円形モードのキャンバス幅 px | number | — | 126 |
| showText | テキストを表示するか | boolean | — | true |
| format | カスタムテキスト内容(クランプ後のパーセンテージを受け取り、ReactNode を返す) | (percentage: number) => ReactNode | — | — |
| sx | レイアウト省略記法 | SxProps | — | — |
Vue 版との対応
percentage / type / status / color / strokeWidth / width / showText は lh-ui-plus の
LhProgress と同名同義。React にスロットはないため、plus の format prop と #text スロットは
1 つの format レンダー関数に統合されます(クランプ後のパーセンテージを受け取り、ReactNode を返す)。
アクセシビリティ
ルート要素は role="progressbar" および aria-valuemin / aria-valuemax / aria-valuenow を持ち、
WAI-ARIA の progressbar パターンに準拠します。aria-valuetext は可視テキストと同期します——
デフォルトではパーセンテージ、format を渡すとフォーマット後のテキストが読み上げられます
(format が文字列以外を返す場合は、四捨五入されたパーセンテージ文にフォールバックします)。
スタイル
import '@lh-ui/react/style/progress'