跳至正文

Fieldset

A semantic group of related form controls named by a legend.

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

交互示例

Fieldset / Legend

默认

Contact preferences

示例

Grouped preferences

Use the first-child legend to name the group and keep a native label on each control.

Fieldset / Legend

Default

Contact preferences
import { Checkbox, Fieldset, FieldsetLegend } from "@gunkin/uiify";

export default function Example() {
  return (
    <Fieldset>
      <FieldsetLegend>Contact preferences</FieldsetLegend>
      <Checkbox id="contact-email" label="Email" name="contact" value="email" />
      <Checkbox id="contact-sms" label="Text message" name="contact" value="sms" />
    </Fieldset>
  );
}

API

Fieldset

属性类型默认值说明
childrenReactNode—Grouped controls and a first-child FieldsetLegend.
className / style / ref / native fieldset propsnative fieldset props—Native fieldset props, styles, events, and ref are forwarded.
renderReactElement | ((props, state) => ReactElement)—替换渲染元素,同时保留行为和无障碍连接关系。

FieldsetLegend

属性类型默认值说明
childrenReactNode—Visible group name rendered as the native legend.
renderReactElement | ((props, state) => ReactElement)—替换渲染元素,同时保留行为和无障碍连接关系。

键盘

按键操作

无障碍

Fieldset and Legend render native fieldset and legend elements. Put FieldsetLegend first to name the group; each contained control still needs its own label. No synthetic group role or hidden legend is added.

样式钩子

data-uiify-fieldsetdata-part="root|legend"