Skip to content

CSS: form-field-group

.instui-form-field-group — 一个带有图例、列或内联布局且间距可配置的 <fieldset> 组。

在字段之间设置其自身的 gap,可通过下面的 -col-spacing-*/-row-spacing-* 修饰符调节 — 优先使用这些,而不是链式使用通用的 -gap-* 间距实用修饰符(后者会直接覆盖内置值)。

Source: form-field-group.css

无障碍

呈现一个原生的 <fieldset> 并带有 <legend>,因此图例文本可为辅助技术命名整个组。

用法

css
@import "@pantoken/components/components.css";
@import "@pantoken/components/form-field-group.css";

示例

html
<fieldset class="instui-form-field-group -layout-columns -col-spacing-medium">
  <legend>Shipping address</legend>
  <label class="instui-form-field">
    <span class="label">First name</span>
    <span class="controls"><input class="instui-text-input"></span>
  </label>
  <label class="instui-form-field">
    <span class="label">Last name</span>
    <span class="controls"><input class="instui-text-input"></span>
  </label>
  <label class="instui-form-field">
    <span class="label">City</span>
    <span class="controls"><input class="instui-text-input"></span>
  </label>
  <label class="instui-form-field">
    <span class="label">State</span>
    <span class="controls">
      <select class="instui-simple-select">
        <option>CA</option>
        <option>NY</option>
        <option>TX</option>
      </select>
    </span>
  </label>
  <div class="instui-form-field-messages">
    <span class="instui-form-field-message -type-hint">All fields are used for delivery only.</span>
  </div>
</fieldset>

结构

text
.instui-form-field-group.-layout-columns.-col-spacing-medium
  legend
  form-field (component)
  form-field-messages (component)
flowchart TD n0[".instui-form-field-group.-layout-columns.-col-spacing-medium"]:::cssdoc-root n1("legend"):::cssdoc-part n2(["form-field"]):::cssdoc-component n3(["form-field-messages"]):::cssdoc-component n0 --> n1 n0 --> n2 n0 --> n3 click n2 "/api/css/form-field.md" click n3 "/api/css/form-field-messages.md" classDef cssdoc-root stroke-width:1px; classDef cssdoc-part stroke-width:1px; classDef cssdoc-slot stroke-width:1px; classDef cssdoc-component stroke-width:1px;

修饰符

修饰符描述
.-col-spacing-large较大的列间距。
.-col-spacing-medium中等列间距。
.-col-spacing-none无列间距。
.-col-spacing-small较小的列间距。
.-layout-aligned将子字段对齐到共享网格。
.-layout-columns以多列方式布局子字段。
.-layout-inline将子字段以内联方式在一行中排列。
.-required将该组标记为必填。
.-row-spacing-large较大的行间距。
.-row-spacing-medium中等行间距。
.-row-spacing-none无行间距。
.-row-spacing-small较小的行间距。
.-v-align-bottom字段底部对齐。
.-v-align-middle字段垂直居中对齐。
.-v-align-top字段顶部对齐。

伪元素

伪元素描述
::after当组为必填时,在图例文本之后渲染装饰性必填字段星号。

条件

类型查询描述
supports(grid-template-columns: subgrid)

消耗代币

Token类型
--instui-component-form-field-layout-asterisk-color<color>LightDarklight-dark(#CF1F24, #FA917F)
--instui-component-form-field-layout-font-family[ <font-family-name> | <generic-font-family> ]#Atkinson Hyperlegible Next, "Helvetica Neue", Helvetica, Arial, sans-serif
--instui-component-form-field-layout-font-size<length>1rem
--instui-component-form-field-layout-font-weight<integer>400
--instui-component-form-field-layout-gap-inputs<length>0.75rem
--instui-component-form-field-layout-gap-primitives<length>0.5rem
--instui-component-form-field-layout-line-height<length>1.125rem
--instui-component-form-field-layout-text-color<color>LightDarklight-dark(#273540, #ffffff)
--instui-spacing-space-lg<length>1rem
--instui-spacing-space-md<length>0.75rem
--instui-spacing-space-sm<length>0.5rem

浏览器支持

  • -layout-aligned 模式在 @supports 保护下使用 CSS 子网格;若子网格不受支持,字段将退回到各自的堆叠布局。

子组件

相关