跳到正文
简体中文

用法

import { DocsFeedback } from './DocsFeedback.jsx'

// Post the answer to your feedback route; resolve false to show the error and keep the answer.
// After Yes, a tap on what helped most is sent again with followUp: true.
<DocsFeedback
  locale="en"
  onSend={async (answer) => {   // { helpful, reasons, comment, followUp? }
    const res = await fetch('/api/feedback', { method: 'POST', body: JSON.stringify({ page: slug, ...answer }) })
    return res.ok
  }}
/>

属性

属性类型默认值作用
locale'en' | 'zh-CN' | 'es' | 'ja''en'内置文字和原因选项的语言。
reasonsArray<{ value, label }>sample reasons选“没帮助”后提供的原因。传空数组则只保留留言框。
likedArray<{ value, label }>sample answers选“有帮助”后提供的“哪一点最有用”选项;点一下会发送 { helpful: true, reasons: [value], followUp: true }。传空数组则不显示这一步。
linksArray<{ label, href, icon? }>sample links底部“更新时间”(labels.updated)旁的其他反馈方式。传空数组则不显示。
maxLengthnumber500留言的最大字数,会在输入框下显示计数。
defaultValue'yes' | 'no' | nullnull初始回答;传 "no" 会直接展开表单。
loading / errorboolean / boolean | stringfalse显示骨架,或带“重新发送”的错误提示(传字符串可替换说明)。
onSend / onRetry(answer) => Promise<boolean | void> / () => void—发送 { helpful, reasons, comment };返回 false 或抛错会显示错误。onRetry 在重新发送前调用。
labelsobject—替换任意内置文字(键名见 copy.js)。

装进你的项目

把指令粘贴给 Codex 或 Claude Code。Agent 会读取公开的源码,先告诉你要写入哪些文件,再把区块连同它用到的组件一起加进项目。

DocsFeedback.jsxdocs-feedback.csscopy.jskit.jsxkit.cssui/base-button/ui/two-step-button/ui/alert-banner/ui/success-check/ui/chip-group/ui/textarea/ui/skeleton-shimmer/tokens.cssREADME.md

区块本身、样式和文案、共用的 kit、用到的组件和 tokens.css 会一起装进同一个文件夹。