Skip to content

CSS: form-field-group

.instui-form-field-group — กลุ่ม <fieldset> ที่มี legend, เลย์เอาต์เป็นคอลัมน์หรือแบบ inline และมีการปรับระยะห่างได้

ตั้งค่า gap ของตัวเองระหว่างฟิลด์ ซึ่งปรับได้ด้วยตัวดัดแต่ง -col-spacing-*/-row-spacing-* ด้านล่าง — ควรใช้ตัวดัดแต่งเหล่านั้นแทนการต่อ chained กับตัวดัดแต่งยูทิลิตี้การเว้นวรรค -gap-* แบบทั่วไป เพราะตัวหลังจะเขียนทับค่าที่ฝังมาโดยตรง

Source: form-field-group.css

การเข้าถึง

เรนเดอร์ <fieldset> เนทีฟพร้อม <legend> เพื่อให้ข้อความใน 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จัดเลย์เอาต์ฟิลด์ย่อยแบบ inline ในแนวนอน
.-requiredระบุให้กลุ่มเป็นฟิลด์ที่ต้องกรอก
.-row-spacing-largeช่องว่างแถวขนาดใหญ่
.-row-spacing-mediumช่องว่างแถวขนาดกลาง
.-row-spacing-noneไม่มีช่องว่างแถว
.-row-spacing-smallช่องว่างแถวขนาดเล็ก
.-v-align-bottomจัดแนวฟิลด์ไปด้านล่าง
.-v-align-middleจัดแนวฟิลด์ตรงกลาง
.-v-align-topจัดแนวฟิลด์ด้านบน

องค์ประกอบเทียม

องค์ประกอบเทียมคำอธิบาย
::afterเรนเดอร์เครื่องหมายดอกจันแสดงฟิลด์ที่ต้องกรอกเป็นองค์ประกอบตกแต่งหลังข้อความ legend เมื่อกลุ่มถูกตั้งเป็น required

เงื่อนไข

ชนิดการค้นหาคำอธิบาย
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 ใช้ CSS subgrid ภายใต้การป้องกันของ @supports; เมื่อเบราว์เซอร์ไม่รองรับ subgrid ฟิลด์จะถอยกลับไปใช้เลย์เอาต์แบบซ้อนกันของตัวเอง

ส่วนประกอบย่อย

ที่เกี่ยวข้อง

  • form-field — ฟิลด์เดี่ยวที่กลุ่มนี้ทำการทำซ้ำ
  • radio-input-group — จัดกลุ่มอินพุตแบบ radio ภายใต้ legend