フィードバック
キャレット
生成中や入力途中のテキストの末尾に表示するマーク。
このページの内容
キャレットは、生成中や入力途中のテキストの末尾に表示する細い縦線です。直前の文字と同じ色で、約1秒に1回の周期でフェードアウトとフェードインを繰り返します。ストリーミング中の回答や、入力を待つプロンプトの末尾で、テキストに続きがあることを伝えます。
キャレット
<div class="message w-full max-w(420)" aria-busy="true"> <div class="message-bubble"> The table has two million rows, so the column is added as nullable first and filled in batches of ten thousand<span class="caret" aria-hidden="true"></span> </div></div><div className="message w-full max-w(420)" aria-busy="true"> <div className="message-bubble"> The table has two million rows, so the column is added as nullable first and filled in batches of ten thousand<span className="caret" aria-hidden="true"></span> </div></div><div class="message w-full max-w(420)" aria-busy="true"> <div class="message-bubble"> The table has two million rows, so the column is added as nullable first and filled in batches of ten thousand<span class="caret" aria-hidden="true"></span> </div></div><template> <div class="message w-full max-w(420)" aria-busy="true"> <div class="message-bubble"> The table has two million rows, so the column is added as nullable first and filled in batches of ten thousand<span class="caret" aria-hidden="true"></span> </div> </div></template>#配置
キャレットはテキストを含む要素の中で、末尾の文字の直後に何も挟まず配置します。行内の文字と同じ高さと色を使うインラインボックスなので、サイズやバリアントの指定は不要です。ページ、カード、インク色のサーフェスで、見出し、段落、コード行のいずれにも使えます。
テキストが完成したらキャレットを削除します。末尾で点滅し続けると、読み手はまだ続きがあると思って待ち続けます。
さまざまなテキストでの使用例
<h3 class="heading heading-lg"> Writing the migration<span class="caret" aria-hidden="true"></span></h3><p class="m(0) text-sm fg-text-body"> Checking the three services that read the column<span class="caret" aria-hidden="true"></span></p><pre class="code-block w-full"><code>$ bun run build<span class="caret caret-block" aria-hidden="true"></span></code></pre><> <h3 className="heading heading-lg"> Writing the migration<span className="caret" aria-hidden="true"></span> </h3> <p className="m(0) text-sm fg-text-body"> Checking the three services that read the column<span className="caret" aria-hidden="true"></span> </p> <pre className="code-block w-full"><code>$ bun run build<span className="caret caret-block" aria-hidden="true"></span></code></pre></><h3 class="heading heading-lg"> Writing the migration<span class="caret" aria-hidden="true"></span></h3><p class="m(0) text-sm fg-text-body"> Checking the three services that read the column<span class="caret" aria-hidden="true"></span></p><pre class="code-block w-full"><code>$ bun run build<span class="caret caret-block" aria-hidden="true"></span></code></pre><template> <h3 class="heading heading-lg"> Writing the migration<span class="caret" aria-hidden="true"></span> </h3> <p class="m(0) text-sm fg-text-body"> Checking the three services that read the column<span class="caret" aria-hidden="true"></span> </p> <pre class="code-block w-full"><code>$ bun run build<span class="caret caret-block" aria-hidden="true"></span></code></pre></template>#ブロックキャレット
caret-blockは、ターミナルで使う幅0.5emのキャレットです。細い縦線が文字に見えやすい、シェルを表示するコードブロックやウィンドウで、コマンドの直後に使います。
#キャレット、シマー、入力中の表示
キャレットは、すでに表示され、さらに続きが追加されるテキストの末尾に使います。テキストがまだなく、短い文言で処理中と伝える場合はシマーを使います。チャットで相手が入力中なら、メッセージにmessage-typingを使います。コントロールの処理待ちにはスピナーを使います。
#アクセシビリティ
- キャレットは装飾なので、
aria-hidden="true"を指定します。 - テキストを生成している領域に
aria-busy="true"を指定し、完成したら外します。スクリーンリーダーは語句が追加されるたびに読み上げるのではなく、完成したテキストをまとめて一度読み上げられます。 prefers-reduced-motion: reduceでは点滅せず、テキストの末尾に静止したキャレットを表示します。
#クラス
| クラス | 説明 |
|---|---|
caret | 直前の文字と同じ色で、文字と同じ高さの細い縦棒です。約 1 秒に 1 回、フェードアウトしてから元の表示に戻ります。 |
caret-block | ターミナルのキャレット。幅は 0.5emcaret と併用します |