components / 35

marked field

validation should explain itself. the same boundary carries rest, focus, dirty, touched, and invalid without changing the native form contract.

shadcnnpx shadcn@latest add berkantay/cheez/marked-field
live

the field remembers the interaction

blur or submit to validate
01 / contact

only used to send the receipt.

dirtytouchedvalid
ink
size
character
controlled valueempty
<MarkedField validationMode="onBlur" tone="orange" size="medium">
  <MarkedFieldLabel required>email</MarkedFieldLabel>
  <MarkedFieldControl
    type="email"
    required
    value={email}
    onValueChange={setEmail}
  />
  <MarkedFieldDescription>only used for receipts</MarkedFieldDescription>
  <MarkedFieldError match="valueMissing">email is required</MarkedFieldError>
  <MarkedFieldError match="typeMismatch">use a complete address</MarkedFieldError>
</MarkedField>
matching

one cause, one useful sentence

native and custom validity
valueMissing
name the project.
typeMismatch
include https://
custom
timing

choose when feedback becomes useful

not every field should interrupt
on submitquiet until asked

best when the form can be completed without immediate correction.

on blurafter the thought

validate when someone leaves the control, not while they are typing.

on changecontinuous signal

use debounce for remote checks and expensive custom rules.

reference

api

Base UI validity, Cheez explanation
partproptypedefaultpurpose
RootvalidationMode"onSubmit" | "onBlur" | "onChange""onSubmit"when validation begins
RootvalidationDebounceTimenumber0delay on-change validation
Rootvalidatefunction—custom sync or async validation
Rootinvalidboolean—external controlled validity
Rootdirty / touchedboolean—external interaction state
RootactionsRefRefObject—imperative validate action
RoottoneMarkedFieldTone"orange"resting boundary ink
Rootsizesmall | medium | large"medium"control density
ControlonValueChangefunction—controlled string value
Controlnative constraintsinput props—required, type, minLength…
Errormatchboolean | keyof ValidityState—show a specific error
LabelnativeLabelbooleantrueassociation behavior
Validitychildrenrender function—inspect the full validity object

behavior notes

  • labels and descriptions associate automatically with the control
  • native constraints and custom validation share one validity model
  • errors can target valueMissing, typeMismatch, rangeOverflow, or any ValidityState key
  • custom validation may return a string, string array, Promise, or null
  • dirty means changed; touched means the control has been visited
  • association, validation timing, and error transitions come from Base UI
  • no Framer Motion is shipped