Skip to content

CSS: form-field

.instui-form-field — 폼 필드 래퍼: 레이블, 해당 컨트롤들, 그리고 인라인·필수·읽기 전용 레이아웃을 포함합니다.

오류 메시지는 필드의 컨트롤이 :user-invalid(사용자가 상호작용한 후)가 되거나 -invalid 클래스를 추가할 때까지 숨겨집니다. 레이블을 컨트롤 옆에 두려면 -layout-inline를, 위에 두려면 -layout-stacked를 사용하세요. 또한 레이블, 컨트롤 및 메시지 사이에 자체 gap를 설정합니다; -gap-* 간격 유틸리티 수식어를 연결하면 그 내장 값을 덮어씁니다.

Source: form-field.css

접근성

<label> 요소는 컨트롤을 래핑하므로 레이블 텍스트가 네이티브하게 그것을 지칭합니다; 필수 표시용 별표는 장식적이며 보조 기술에서 숨겨야 합니다(aria-hidden). 오류 메시지는 컨트롤이 :user-invalid가 되거나 -invalid 클래스를 추가하면 표시됩니다.

사용법

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

예제들

html
<label class="instui-form-field">
  <span class="label">Email address</span>
  <span class="controls"><input class="instui-text-input" type="email" placeholder="[email protected]"></span>
  <div class="instui-form-field-messages">
    <span class="instui-form-field-message -type-hint">We'll never share it.</span>
    <span class="instui-form-field-message -type-error">Enter a valid email address.</span>
  </div>
</label>

구조

text
.instui-form-field
  .label
  .controls
    text-input (component)
  form-field-messages (component)
flowchart TD n0[".instui-form-field"]:::cssdoc-root n1(".label"):::cssdoc-part n2(".controls"):::cssdoc-part n3(["text-input"]):::cssdoc-component n4(["form-field-messages"]):::cssdoc-component n0 --> n1 n2 --> n3 n0 --> n2 n0 --> n4 click n3 "/api/css/text-input.md" click n4 "/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;

수정자

수정자설명
.-inline인라인 레이아웃(-layout-inline의 축약형).
.-invalid무효(오류) 상태입니다.
.-label-align-end레이블 텍스트를 끝(오른쪽)에 정렬합니다.
.-label-align-start레이블 텍스트를 시작(왼쪽)으로 정렬합니다.
.-layout-inline인라인 레이아웃: 레이블이 컨트롤 옆에 배치됩니다.
.-layout-stacked스택형 레이아웃: 레이블이 컨트롤 위에 배치됩니다.
.-readonly읽기 전용 상태입니다.
.-v-align-bottom레이블을 컨트롤과 아래쪽 정렬합니다.
.-v-align-top레이블을 컨트롤과 위쪽 정렬합니다.

부분

부분설명
.controls레이블 옆이나 아래에 위치한 컨트롤 영역입니다.
.label필드 레이블입니다.

의사 요소

의사 요소설명
::after필드가 필수일 때 레이블 텍스트 뒤에 장식용 필수 별표를 렌더링합니다.

상태

상태설명
:required

사용된 토큰

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-readonly-text-color<color>LightDarklight-dark(#576773, #AAB0B5)
--instui-component-form-field-layout-text-color<color>LightDarklight-dark(#273540, #ffffff)

브라우저 지원

  • CSS @scope at-rule로 요소 스타일을 포함합니다; 최신 Chromium, Firefox 또는 Safari가 필요합니다.

하위 컴포넌트

관련 항목

  • form-field-messages — 필드의 힌트, 오류 및 성공 메시지를 렌더링합니다.
  • form-field-group — 관련 필드들을 공통 레전드 아래에 그룹화합니다.