Octri

提示框

提示框用于提醒读者注意不容错过的内容:破坏性操作前的警告、节省时间的提示,或有关边界情况的说明。它是一个带有色彩背景的框,包含图标、可选标题以及任意 Markdown 内容。

示例

保存不等于发布

发布之前,读者始终会看到上一次发布的版本。

mdx
<Callout type="warning" title="Saving is not publishing">
  Readers keep seeing the last published version until you publish.
</Callout>

属性

typestring默认值:info

提示框的类型,用于设置其颜色和图标。

值适用场景
note读者可能需要的额外细节
info读者能从中受益但可以跳过的背景信息
tip捷径,或更好的做法,帮助读者改进正在进行的操作
success确认操作已成功
warning如果操作有误,会耗费时间或导致数据损失的事项
danger具有破坏性且难以撤销的操作
error出错的事项

variant 也可用作它的另一个名称。

titlestring

位于内容上方的粗体标题。对于只有一两句话的提示框,可以省略标题。

childrenMarkdown

标签之间的内容。可以包含段落、列表、链接和代码。开始标签后和结束标签前都要留一个空行,否则其中的 Markdown 不会被解析。

所有类型

note

读者可能需要的额外细节。

info

读者能从中受益但可以跳过的背景信息。

tip

捷径,或更好的做法,帮助读者改进正在进行的操作。

success

确认操作已成功。

warning

如果操作有误,会耗费时间或导致数据损失的事项。

danger

具有破坏性且难以撤销。

error

出了点问题。

mdx
<Callout type="note" title="note">
  Extra detail a reader may want.
</Callout>

<Callout type="info" title="info">
  Context a reader benefits from but can skip.
</Callout>

<Callout type="tip" title="tip">
  A shortcut, or a better way to do what they're already doing.
</Callout>

<Callout type="success" title="success">
  Confirmation that something worked.
</Callout>

<Callout type="warning" title="warning">
  Something that will cost them time or data if they get it wrong.
</Callout>

<Callout type="danger" title="danger">
  Destructive and hard to undo.
</Callout>

<Callout type="error" title="error">
  Something that has gone wrong.
</Callout>

简写标签

<Note>、<Info>、<Tip> 和 <Warning> 是这种类型的提示框,因此为 Mintlify 或 Fern 编写的页面无需改写即可使用。它们也支持 title。

使用沙盒

测试密钥不会扣款。

mdx
<Tip title="Use the sandbox">
  Test keys never charge a card.
</Tip>

编写优质提示框

  • 少量使用。 如果所有内容都突出显示,就没有什么能脱颖而出了。每页使用一两个提示框,才能让它们发挥作用。
  • 根据后果选择类型。 如果读者跳过 warning 和 danger 会有所损失,就应该使用它们。
  • 在标题中点明要点。 即使只是快速浏览,读者也应该能单凭标题了解信息。
  • 徽标:句子中的简短彩色标签。
  • 折叠面板:大多数读者可以跳过的详细内容。
  • 所有组件:完整列表以及编写标签的规则。