For AI agents: the complete documentation index is available at https://a3s-lab.github.io/UI/v0.4.1/llms.txt, the full documentation bundle is available at https://a3s-lab.github.io/UI/v0.4.1/llms-full.txt, and this page is available as Markdown at https://a3s-lab.github.io/UI/v0.4.1/components/form.md.

表单

把相关字段、校验摘要和提交操作组织为一个可恢复的任务,并保留浏览器原生提交语义。

保存工作区

显示在导航与邀请中。请使用 2 到 40 个字符。

用于接收发布通知与所有权转移。

可以保存工作区。

只读发布记录

只有发布所有者可以重命名已发布的工作区。

当前值仍会参与提交,但不可编辑。

用法

导入 Tailwind 与完整的 A3S UI 样式包:

@import "tailwindcss";
@import "@a3s-lab/ui/a3s.css";

使用 form.form 表达一个可恢复任务。Field 负责每个控件的标签与局部错误;Form 负责分组、摘要校验、提交状态与页脚操作。

<form class="form" novalidate>
  <div data-form-summary role="alert" hidden></div>
  <div class="field">
    <label for="workspace-name">工作区名称</label>
    <input id="workspace-name" class="input" name="workspaceName" required />
    <p data-form-error role="alert" hidden>请输入工作区名称。</p>
  </div>
  <footer>
    <button class="btn" type="submit">保存工作区</button>
    <button class="btn" type="reset" data-variant="outline">重置</button>
  </footer>
</form>

参数

契约用途
form.form一次提交任务的规范原生根
[data-form-summary]可选的多项失败摘要;校验前保持为空
[data-form-error] / [role=alert]局部或摘要恢复文案;仅在失败后展示
带 type="submit" / type="reset" 的 footer同一任务的主操作与重置
data-state="submitting" / aria-busy="true"进行中时阻止重复编辑与操作
data-state="invalid" / aria-invalid="true"提交后表单级校验失败
data-state="success"本地成功反馈,且不清除已输入值
data-state="error"宿主报告失败,保留值与恢复焦点
data-readonly / data-state="read-only"只读呈现,并配对原生 readonly / 禁用提交

契约

接口值
根选择器form.form
原生根元素<form>
状态ready, submitting, success, invalid, error, read-only
事件reset, submit
方法—

产品边界

表单负责交互结构,不负责网络请求、权限或业务校验。不要把不相关设置塞进同一表单,也不要用禁用按钮代替具体错误说明。

组件只发布可复用的交互边界。数据获取、持久化、权限、可信内容与业务实体继续由宿主产品拥有。

可访问性

错误靠近字段并可从摘要定位;提交中保留输入,失败后保持焦点上下文。所有字段都需要持久可见的标签。当 aria-busy="true" 时,指针交互会被锁定,避免重复提交与首次请求竞态。