表示例
68%
別名・英語表記
- 進捗バー
- 進行状況
- ロードバー
- プログレス
- 進み具合
- 何パーセント
- Progress bar
実装例
<div class="x-progress">
<div class="x-progress__row">
<label class="x-progress__l" for="x-progress-p">アップロード中</label>
<span class="x-progress__v">68%</span>
</div>
<progress class="x-progress__b" id="x-progress-p" max="100" value="68">68%</progress>
</div>
/* 貼った先のリセットに頼らないよう、この部品の中だけ border-box にする */
.x-progress,
.x-progress *:not([class*="fa-"]),
.x-progress *:not([class*="fa-"])::before,
.x-progress *:not([class*="fa-"])::after {
box-sizing: border-box;
/* 貼った先の既定の書体に引きずられないようにする。書体が変わると
文字の幅と高さが変わり、枠のサイズまでずれる */
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
}
.x-progress {
width: 250px;
}
.x-progress__row {
display: flex;
justify-content: space-between;
margin-bottom: 6px;
}
.x-progress__l {
font-size: 12px;
font-weight: 700;
}
.x-progress__v {
font-size: 12px;
font-variant-numeric: tabular-nums;
color: #606a7b;
}
.x-progress__b {
appearance: none;
width: 100%;
height: 8px;
border: 0;
border-radius: 999px;
background: #e3e6ea;
overflow: hidden;
}
.x-progress__b::-webkit-progress-bar {
background: #e3e6ea;
}
.x-progress__b::-webkit-progress-value {
background: #1d4ed8;
}
.x-progress__b::-moz-progress-bar {
background: #1d4ed8;
}
AIへの指示文
「プログレスバー(Progress bar)」を実装してください。
## これは何か
どこまで進んだかを、伸びる帯で示す部品。終わりが見えている処理に使う。
## 使いどころ
- アップロードや書き出しなど、全体量が分かっている処理
- 入力が複数段に分かれていて、あと何段かを示したいとき
## 実装の要件
- progress 要素 + 数値の表示
- 不確定のときは value を外し、スピナーへ切り替える
- 終わりが分からない処理に使わない。そこはスピナーの役目
- 数字を出さないと、残りがどのくらいか伝わらない
- 進み方が止まると壊れたように見える。段階ごとに文言を変えると安心される
## アクセシビリティの要件
- progress 要素を使うか、role="progressbar" に aria-valuenow / valuemin / valuemax を付ける
- 進捗の数値は文字でも表示する。バーの長さだけにしない
- 更新のたびに読み上げさせない。aria-live は付けず、節目だけ知らせる
## 参考にする実装
この形を出発点にして、プロジェクトの命名規則・色・余白に合わせて調整してください。
```html
<div class="x-progress">
<div class="x-progress__row">
<label class="x-progress__l" for="x-progress-p">アップロード中</label>
<span class="x-progress__v">68%</span>
</div>
<progress class="x-progress__b" id="x-progress-p" max="100" value="68">68%</progress>
</div>
```
```css
/* 貼った先のリセットに頼らないよう、この部品の中だけ border-box にする */
.x-progress,
.x-progress *:not([class*="fa-"]),
.x-progress *:not([class*="fa-"])::before,
.x-progress *:not([class*="fa-"])::after {
box-sizing: border-box;
/* 貼った先の既定の書体に引きずられないようにする。書体が変わると
文字の幅と高さが変わり、枠のサイズまでずれる */
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
}
.x-progress {
width: 250px;
}
.x-progress__row {
display: flex;
justify-content: space-between;
margin-bottom: 6px;
}
.x-progress__l {
font-size: 12px;
font-weight: 700;
}
.x-progress__v {
font-size: 12px;
font-variant-numeric: tabular-nums;
color: #606a7b;
}
.x-progress__b {
appearance: none;
width: 100%;
height: 8px;
border: 0;
border-radius: 999px;
background: #e3e6ea;
overflow: hidden;
}
.x-progress__b::-webkit-progress-bar {
background: #e3e6ea;
}
.x-progress__b::-webkit-progress-value {
background: #1d4ed8;
}
.x-progress__b::-moz-progress-bar {
background: #1d4ed8;
}
```
## 出力の約束
- HTML と CSS を分けて出す。JavaScript が要るときは素の JavaScript で書き、UIフレームワークは使わない。
- 参考実装がアイコンに Font Awesome のクラスを使っている場合は、プロジェクトで使っているアイコンかインライン SVG に置き換えてよい。
- 上のアクセシビリティ要件を満たす。満たせない箇所があるときは、理由を添えて先に知らせる。
- 色・角丸・余白は既存のデザイントークンがあればそれを使う。無ければ CSS 変数として切り出す。
使いどころ
- アップロードや書き出しなど、全体量が分かっている処理
- 入力が複数段に分かれていて、あと何段かを示したいとき
注意点
- 終わりが分からない処理に使わない。そこはスピナーの役目
- 数字を出さないと、残りがどのくらいか伝わらない
- 進み方が止まると壊れたように見える。段階ごとに文言を変えると安心される
アクセシビリティの要点
- progress 要素を使うか、role="progressbar" に aria-valuenow / valuemin / valuemax を付ける
- 進捗の数値は文字でも表示する。バーの長さだけにしない
- 更新のたびに読み上げさせない。aria-live は付けず、節目だけ知らせる