フィードバック
アラート
ページの流れの中に表示するメッセージ。必要に応じてステータスを付けられます。
このページの内容
アラートは、そのページに関するメッセージを本文の流れの中に表示するコンポーネントです。平らな面を 0.5px の輪郭で囲みます。ステータスに応じて背景を淡く色づけ、アイコンの色を変えます。テキストは通常の文字色を保ち、色だけに頼らず意味を伝えます。
アラート
<div class="alert" role="status"> <svg class="icon alert-icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <circle cx="8" cy="8" r="6" /><circle cx="8" cy="5" r="0.5" fill="currentColor" stroke="none" /><path d="M8 8L8 11" /> </svg> <div class="alert-body"> <p class="alert-title">A new version is available</p> <p class="alert-description">Reload to use the latest build of the dashboard.</p> </div> <button type="button" class="btn btn-sm">Reload</button></div>import InfoCircleIcon from '@master/icons-react/native/16/soft/info-circle'<div className="alert" role="status"> <InfoCircleIcon className="icon alert-icon" /> <div className="alert-body"> <p className="alert-title">A new version is available</p> <p className="alert-description">Reload to use the latest build of the dashboard.</p> </div> <button type="button" className="btn btn-sm">Reload</button></div><script> import InfoCircleIcon from '@master/icons-svelte/native/16/soft/info-circle'</script><div class="alert" role="status"> <InfoCircleIcon class="icon alert-icon" /> <div class="alert-body"> <p class="alert-title">A new version is available</p> <p class="alert-description">Reload to use the latest build of the dashboard.</p> </div> <button type="button" class="btn btn-sm">Reload</button></div><script setup>import InfoCircleIcon from '@master/icons-vue/native/16/soft/info-circle'</script><template> <div class="alert" role="status"> <InfoCircleIcon class="icon alert-icon" /> <div class="alert-body"> <p class="alert-title">A new version is available</p> <p class="alert-description">Reload to use the latest build of the dashboard.</p> </div> <button type="button" class="btn btn-sm">Reload</button> </div></template>#ステータス
読み手に必要な対応に応じてステータスを選び、その意味が文面からも伝わるようにします。
alert-infoは、状況をすぐに変えるものではない補足情報を伝えます。alert-successは、直前の処理が完了したことを伝えます。alert-warningは、問題が起きる前に注意を促します。alert-dangerは、処理の失敗や操作を続行できないことを伝えます。
ステータス
<div class="alert alert-info" role="status"> <svg class="icon alert-icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <circle cx="8" cy="8" r="6" /><circle cx="8" cy="5" r="0.5" fill="currentColor" stroke="none" /><path d="M8 8L8 11" /> </svg> <div class="alert-body"> <p class="alert-description">Scheduled maintenance on Sunday from 02:00 to 03:00 UTC.</p> </div></div><div class="alert alert-success" role="status"> <svg class="icon alert-icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <circle cx="8" cy="8" r="6" /><path d="M5 8L7.1041 9.8703A0.2 0.2 0 0 0 7.3832 9.8573L10.75 6.25" /> </svg> <div class="alert-body"> <p class="alert-description">Your domain is verified and serving traffic.</p> </div></div><div class="alert alert-warning" role="status"> <svg class="icon alert-icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <path d="M8.8742 3.8235L13.4246 12.0144A1 1 0 0 1 12.5505 13.5L3.4495 13.5A1 1 0 0 1 2.5754 12.0144L7.1258 3.8235A1 1 0 0 1 8.8742 3.8235Z" /><path d="M8 6.5L8 9" /><circle cx="8" cy="11.5" r="0.5" fill="currentColor" stroke="none" /> </svg> <div class="alert-body"> <p class="alert-title">Your card expires this month</p> <p class="alert-description">Update the payment method to keep deployments running.</p> </div> <button type="button" class="btn btn-sm">Update</button></div><div class="alert alert-danger" role="alert"> <svg class="icon alert-icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <circle cx="8" cy="8" r="6" transform="rotate(180 8 8)" /><circle cx="8" cy="5" r="0.5" fill="currentColor" stroke="none" transform="rotate(180 8 8)" /><path d="M8 8L8 11" transform="rotate(180 8 8)" /> </svg> <div class="alert-body"> <p class="alert-title">The build failed</p> <p class="alert-description"> The install step exited with code 1. Read the logs for the missing dependency. </p> </div></div>import InfoCircleIcon from '@master/icons-react/native/16/soft/info-circle'import CheckCircleIcon from '@master/icons-react/native/16/soft/check-circle'import AlertTriangleIcon from '@master/icons-react/native/16/soft/alert-triangle'import AlertCircleIcon from '@master/icons-react/native/16/soft/alert-circle'<> <div className="alert alert-info" role="status"> <InfoCircleIcon className="icon alert-icon" /> <div className="alert-body"> <p className="alert-description">Scheduled maintenance on Sunday from 02:00 to 03:00 UTC.</p> </div> </div> <div className="alert alert-success" role="status"> <CheckCircleIcon className="icon alert-icon" /> <div className="alert-body"> <p className="alert-description">Your domain is verified and serving traffic.</p> </div> </div> <div className="alert alert-warning" role="status"> <AlertTriangleIcon className="icon alert-icon" /> <div className="alert-body"> <p className="alert-title">Your card expires this month</p> <p className="alert-description">Update the payment method to keep deployments running.</p> </div> <button type="button" className="btn btn-sm">Update</button> </div> <div className="alert alert-danger" role="alert"> <AlertCircleIcon className="icon alert-icon" /> <div className="alert-body"> <p className="alert-title">The build failed</p> <p className="alert-description"> The install step exited with code 1. Read the logs for the missing dependency. </p> </div> </div></><script> import InfoCircleIcon from '@master/icons-svelte/native/16/soft/info-circle' import CheckCircleIcon from '@master/icons-svelte/native/16/soft/check-circle' import AlertTriangleIcon from '@master/icons-svelte/native/16/soft/alert-triangle' import AlertCircleIcon from '@master/icons-svelte/native/16/soft/alert-circle'</script><div class="alert alert-info" role="status"> <InfoCircleIcon class="icon alert-icon" /> <div class="alert-body"> <p class="alert-description">Scheduled maintenance on Sunday from 02:00 to 03:00 UTC.</p> </div></div><div class="alert alert-success" role="status"> <CheckCircleIcon class="icon alert-icon" /> <div class="alert-body"> <p class="alert-description">Your domain is verified and serving traffic.</p> </div></div><div class="alert alert-warning" role="status"> <AlertTriangleIcon class="icon alert-icon" /> <div class="alert-body"> <p class="alert-title">Your card expires this month</p> <p class="alert-description">Update the payment method to keep deployments running.</p> </div> <button type="button" class="btn btn-sm">Update</button></div><div class="alert alert-danger" role="alert"> <AlertCircleIcon class="icon alert-icon" /> <div class="alert-body"> <p class="alert-title">The build failed</p> <p class="alert-description"> The install step exited with code 1. Read the logs for the missing dependency. </p> </div></div><script setup>import InfoCircleIcon from '@master/icons-vue/native/16/soft/info-circle'import CheckCircleIcon from '@master/icons-vue/native/16/soft/check-circle'import AlertTriangleIcon from '@master/icons-vue/native/16/soft/alert-triangle'import AlertCircleIcon from '@master/icons-vue/native/16/soft/alert-circle'</script><template> <div class="alert alert-info" role="status"> <InfoCircleIcon class="icon alert-icon" /> <div class="alert-body"> <p class="alert-description">Scheduled maintenance on Sunday from 02:00 to 03:00 UTC.</p> </div> </div> <div class="alert alert-success" role="status"> <CheckCircleIcon class="icon alert-icon" /> <div class="alert-body"> <p class="alert-description">Your domain is verified and serving traffic.</p> </div> </div> <div class="alert alert-warning" role="status"> <AlertTriangleIcon class="icon alert-icon" /> <div class="alert-body"> <p class="alert-title">Your card expires this month</p> <p class="alert-description">Update the payment method to keep deployments running.</p> </div> <button type="button" class="btn btn-sm">Update</button> </div> <div class="alert alert-danger" role="alert"> <AlertCircleIcon class="icon alert-icon" /> <div class="alert-body"> <p class="alert-title">The build failed</p> <p class="alert-description"> The install step exited with code 1. Read the logs for the missing dependency. </p> </div> </div></template>#レイアウト
アラートは --alert-radius を使用し、既定値は var(--radius-control-lg) です。トレイの直下に配置する場合は、アラートのこのプロパティを var(--radius-surface) に設定して、トレイの角丸と内側の余白に合わせます。
アイコンに icon alert-icon を指定すると、本文が何行あっても、1 行目の上下中央に揃います。alert-body は残りの幅を使います。本文の後に置いたボタンやリンクは行末に配置され、アラートの幅が狭いときは本文の下に折り返します。
狭いカラムでの表示
<div class="alert alert-warning max-w(280) mx-auto" role="status"> <svg class="icon alert-icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <path d="M8.8742 3.8235L13.4246 12.0144A1 1 0 0 1 12.5505 13.5L3.4495 13.5A1 1 0 0 1 2.5754 12.0144L7.1258 3.8235A1 1 0 0 1 8.8742 3.8235Z" /><path d="M8 6.5L8 9" /><circle cx="8" cy="11.5" r="0.5" fill="currentColor" stroke="none" /> </svg> <div class="alert-body"> <p class="alert-title">Usage is at 90%</p> <p class="alert-description">Requests are limited when the plan runs out.</p> </div> <button type="button" class="btn btn-sm">Upgrade</button></div>import AlertTriangleIcon from '@master/icons-react/native/16/soft/alert-triangle'<div className="alert alert-warning max-w(280) mx-auto" role="status"> <AlertTriangleIcon className="icon alert-icon" /> <div className="alert-body"> <p className="alert-title">Usage is at 90%</p> <p className="alert-description">Requests are limited when the plan runs out.</p> </div> <button type="button" className="btn btn-sm">Upgrade</button></div><script> import AlertTriangleIcon from '@master/icons-svelte/native/16/soft/alert-triangle'</script><div class="alert alert-warning max-w(280) mx-auto" role="status"> <AlertTriangleIcon class="icon alert-icon" /> <div class="alert-body"> <p class="alert-title">Usage is at 90%</p> <p class="alert-description">Requests are limited when the plan runs out.</p> </div> <button type="button" class="btn btn-sm">Upgrade</button></div><script setup>import AlertTriangleIcon from '@master/icons-vue/native/16/soft/alert-triangle'</script><template> <div class="alert alert-warning max-w(280) mx-auto" role="status"> <AlertTriangleIcon class="icon alert-icon" /> <div class="alert-body"> <p class="alert-title">Usage is at 90%</p> <p class="alert-description">Requests are limited when the plan runs out.</p> </div> <button type="button" class="btn btn-sm">Upgrade</button> </div></template>#アクセシビリティ
- ページの読み込み後に表示されるアラートには、ライブリージョンが必要です。
role="status"は読み上げの切れ目を待ち、role="alert"は進行中の読み上げに割り込みます。role="alert"は、すぐに対応が必要なエラーに限って使います。 - ページに最初から含まれるアラートには、ロールの指定は不要です。
- アイコンには
aria-hidden="true"を指定します。メッセージはテキストで伝えます。
#クラス
| クラス | 説明 |
|---|---|
alert | 中立的なメッセージです。平らな面を 0.5px の線で囲みます。本文に続くボタンやリンクは行末に配置し、アラートの幅が狭いときは本文の下に折り返します。 |
alert-info | まだ状況が変わっていない段階の補足情報です。情報色の淡い背景と、同系色のアイコンで示します。alert と併用します |
alert-success | 直前に完了した処理を、成功を示す淡い背景色と、同系色のアイコンで示します。alert と併用します |
alert-warning | 問題が起きる前の注意喚起です。警告色の淡い背景と、同系色のアイコンで示します。alert と併用します |
alert-danger | 失敗や実行できない操作を、危険を示す淡い背景色と、同系色のアイコンで示します。alert と併用します |
alert-icon | アイコンに icon と併せて指定します。テキストが何行あっても、アイコンの中心を 1 行目の中央に合わせます。 |
alert-body | テキストを収め、残りの幅を占める領域 |
alert-title | メッセージの要点を短い文言で示し、強調します。 |
alert-description | タイトルの下に表示する文です。タイトルがない場合は、メッセージ全文を表示します。 |
#カスタムプロパティ
| プロパティ | 既定値 | 説明 |
|---|---|---|
--alert-radius | var(--radius-control-lg) | 角のスケールを適用する前の円弧の半径です。トレイに直接収める場合は var(--radius-surface) を使います。指定先:alert |