Form
Constraint-API form + field wiring
Use the browser's own validation — required, type="email", minlength, pattern — and let BlessField show the message. There is no schema, no rules object, nothing to import for the common case.
Basic
How the wiring works
BlessFieldgives the first control inside it the label'sforid,aria-invalidwhile it shows an error, andaria-describedbypointing at the description and the error; the description stays under an error, since it is usually what fixes it. Every Bless control takes them; nothing to pass. The slot props (id,error,describedby) remain for a plain<input>or a field with two controls.- A native validation message appears on the browser's
invalidevent (a submit) or on blur — but blur only once the field has a value or the form has been submitted, so tabbing through an empty form stays quiet. erroris for what the browser can't know: the server said no. It wins over the native message while set; clear it when the user edits.BlessFormsetsnovalidateso the browser's own bubble never shows; the field speaks instead.@submitfires with(FormData, event)only when everything is valid;@invalidfires with the form element on a failed submit, after focus has moved to the first invalid control. Reset clears every field's message, and everyv-modelinside follows the reset values.#default="{ submitted }"tells you whether a submit has been tried — for a summary line or a disabled button.
Usage
ts
import { BlessForm, BlessField } from "blessing-ui";API
BlessForm
Events
| Name | Payload | Description |
|---|---|---|
submit | [data: FormData, event: SubmitEvent] | |
invalid | [form: HTMLFormElement] |
Slots
| Name | Scope | Description |
|---|---|---|
default | { submitted: boolean; } |
Exposed
| Name | Type | Description |
|---|---|---|
reset | () => void | |
el | HTMLFormElement |
BlessField
Props
| Name | Type | Default | Description |
|---|---|---|---|
label | string | — | |
hint | string | — | |
required | boolean | — | |
description | string | — | |
error | string | — | explicit error; otherwise read from the control's validity after submit/blur |
id | string | — |
Slots
| Name | Scope | Description |
|---|---|---|
default | { id: string; error: string; describedby: string | undefined; } |