反馈
光标
位于仍在输入或生成的文字末尾。
本页内容
光标是仍在输入或生成的文本末尾的一道细竖线,颜色与前面的文字相同,约每秒淡出再淡入一次。流式回答的末尾或等待输入的提示符后,文字本身无法表明后面还有内容,光标便用来传达这一状态。
光标
<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 是终端使用的宽光标,宽度为半个 em。细竖线容易被误认成字母,因此在代码块或显示 shell 的窗口中,应在命令后使用块状光标。
#光标、微光或输入提示
光标跟在已经出现且仍在增加的文字后。如果内容尚未出现,通过简短文字提示正在处理,请使用微光效果。对话中的另一方正在输入时,可在消息上使用 message-typing。控件自身处于等待状态时,使用加载指示器。
#无障碍
- 光标是装饰元素,为它设置
aria-hidden="true"。 - 用
aria-busy="true"标记正在生成文本的区域,文本完成后移除该标记。这样,屏幕阅读器可以在生成结束后一次读出完整文本,避免随内容更新逐词朗读。 - 在
prefers-reduced-motion: reduce下,光标静止在文本末尾。
#类名
| 类名 | 说明 |
|---|---|
caret | 一条与前方文字同色、与字符等高的细竖线,大约每秒淡出再淡入一次 |
caret-block | 终端光标,宽 0.5em与 caret 一同使用 |