Skip to content

Form ​

gk-form and gk-form-item lay out labels, required marks, and validation messages around Input, Select, InputNumber, Rate, Cascader, Upload, TreeSelect, and Transfer. They do not replace those controls.

Labels default to the left, 7.5rem wide in the demo, aligned right. The component does not switch layout at a breakpoint. Bind label-placement="top" below about 640px.

Demos ​

Order

The email starts invalid so the error is visible. Submit runs validate() and emits submit with { model } only when every item passes. Validators are synchronous.
台北市新北市件最多 200 字送出重設

Labels on top

Feedback off, warning, disabled

Narrow screens ​

html
<gk-form :label-placement="narrow ? 'top' : 'left'" label-width="7.5rem">

Keep that binding in the app. Inline forms are for wide screens only.

API ​

gk-form ​

NameTypeDefault
modelobject{}
rulesRecord<path, Rule | Rule[]>{}
sizesm | md | lgmd
label-placementleft | topleft
label-widthstringauto
label-alignleft | rightright when placement is left
inlinebooleanfalse
disabledbooleanfalse
show-label / show-require-mark / show-feedbackbooleantrue

validate() returns Promise<{ valid, errors: { path, message }[] }>. restoreValidation() clears item errors. submit fires with { model } only when valid. Reset keeps the same model object.

A rule is { required?, message?, pattern?, min?, max?, validator? }. validator must be synchronous. A Promise becomes the message「尚不支援非同步驗證」.

gk-form-item ​

NameTypeDefaultNotes
label / pathstring—
requiredbooleanfalseShows the mark even without a required rule
ruleRule | Rule[]—Overrides the form rule for that path
feedbackstring—Wins over the failed rule text
validation-statussuccess | warning | error—Drives child status when the child has one
helpstring—Shown when there is no error
show-label / show-feedback / show-require-markbooleaninheritUse a property binding for false

Parts: row, label, mark, control, help, feedback, extra.

The required asterisk is real text with aria-hidden="true". The control gets aria-required. Errors set aria-invalid and aria-describedby. When show-label is false, give the control its own accessible name.

gk-rate has no status border; the feedback text is the error cue. Known status children are Input, Select, InputNumber, Cascader, Date Picker, and TreeSelect. Upload and Transfer use the feedback text the same way Rate does.