跳至正文

Form Error Summary

A server-rendered summary linking each error to its field.

浏览器
Chrome 123+Firefox 121+Safari 17.5+
层级
0
强制布局预算
0 ms
axe 预算
0
支持 SSR
是
公开契约
测试环境

交互示例

Form Error Summary

There is a problem

Enter a valid email address

Use at least 8 characters

示例

A single field error

The summary link focuses the matching field. Keep the same error below the field with aria-describedby; the static summary does not announce or move focus automatically.

There is a problem

Choose a project name

import { FormErrorSummary, Input } from "@gunkin/uiify";

export default function Example() {
  return (
    <form className="example-form" aria-label="Project details">
      <FormErrorSummary aria-label="Project errors" title="There is a problem" errors={[{ href: "#form-error-summary-single-project", message: "Choose a project name" }]} />
      <div className="example-field">
        <label htmlFor="form-error-summary-single-project">Project name</label>
        <Input id="form-error-summary-single-project" name="project" invalid autoComplete="off" aria-describedby="form-error-summary-single-project-error" />
        <p className="example-error" id="form-error-summary-single-project-error">Choose a project name</p>
      </div>
    </form>
  );
}

API

FormErrorSummary

属性类型默认值说明
title*ReactNode—Visible heading for the summary.
errors*readonly { href: string; message: ReactNode }[]—Each href must target the id of its corresponding field.
className / style / ref / native section propsnative section props—Native section props, styles, events, and ref are forwarded.
renderReactElement | ((props, state) => ReactElement)—替换渲染元素,同时保留行为和无障碍连接关系。

键盘

按键操作

无障碍

Static section containing a heading and links to the supplied error targets. Every href must point to a real field id. This summary adds no alert role, live region, focus movement, or validation logic; fields retain their labels and inline aria-describedby relationships. Empty errors render nothing.

样式钩子

data-uiify-form-error-summarydata-part="title|list|item|link"
本页由机器翻译,尚未经人工审核。