v1.3.0 28

Form

Form layout patterns with labels, inputs, validation states, and helper text.

Login Form

Standard vertical form layout with email and password fields.

html
<form class="vt-form vt-w-full vt-max-w-sm" onsubmit="event.preventDefault()">
  <div class="vt-field">
    <label class="vt-label" for="login-email">Email</label>
    <div class="vt-relative">
      <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16" fill="none" class="vt-absolute vt-left-3 vt-top-1/2 vt--translate-y-1/2 vt-text-foreground-muted" aria-hidden="true">
        <path d="M2 6L8.91302 9.91697C11.4616 11.361 12.5384 11.361 15.087 9.91697L22 6" stroke="currentColor" stroke-linejoin="round" stroke-width="1.5"></path><path d="M2.01577 13.4756C2.08114 16.5412 2.11383 18.0739 3.24496 19.2094C4.37608 20.3448 5.95033 20.3843 9.09883 20.4634C11.0393 20.5122 12.9607 20.5122 14.9012 20.4634C18.0497 20.3843 19.6239 20.3448 20.7551 19.2094C21.8862 18.0739 21.9189 16.5412 21.9842 13.4756C22.0053 12.4899 22.0053 11.5101 21.9842 10.5244C21.9189 7.45886 21.8862 5.92609 20.7551 4.79066C19.6239 3.65523 18.0497 3.61568 14.9012 3.53657C12.9607 3.48781 11.0393 3.48781 9.09882 3.53656C5.95033 3.61566 4.37608 3.65521 3.24495 4.79065C2.11382 5.92608 2.08114 7.45885 2.01576 10.5244C1.99474 11.5101 1.99475 12.4899 2.01577 13.4756Z" stroke="currentColor" stroke-linejoin="round" stroke-width="1.5"></path>
      </svg>
      <input id="login-email" type="email" placeholder="you@example.com" class="vt-input vt-pl-10">
    </div>
  </div>
  <div class="vt-field">
    <label class="vt-label" for="login-password">Password</label>
    <div class="vt-relative">
      <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16" fill="none" class="vt-absolute vt-left-3 vt-top-1/2 vt--translate-y-1/2 vt-text-foreground-muted" aria-hidden="true">
        <path d="M22 12C22 17.5228 17.5228 22 12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12Z" stroke="currentColor" stroke-width="1.5"></path><path d="M12 13C13.1046 13 14 12.1046 14 11C14 9.89543 13.1046 9 12 9C10.8954 9 10 9.89543 10 11C10 12.1046 10.8954 13 12 13ZM12 13L12 16" stroke="currentColor" stroke-linecap="round" stroke-width="1.5"></path>
      </svg>
      <input id="login-password" type="password" placeholder="Enter password" class="vt-input vt-pl-10">
    </div>
  </div>
  <div class="vt-form-actions vt-form-actions-block">
    <button type="submit" class="vt-btn vt-btn-primary"><span>Sign in</span></button>
  </div>
</form>

With Helper Text

Form fields with hint text below the input.

html

Must be 3-20 characters, letters and numbers only

Maximum 160 characters

<div class="vt-form vt-w-full vt-max-w-sm">
  <div class="vt-field">
    <label class="vt-label" for="helper-username">Username</label>
    <div class="vt-relative">
      <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16" fill="none" class="vt-absolute vt-left-3 vt-top-1/2 vt--translate-y-1/2 vt-text-foreground-muted" aria-hidden="true">
        <path d="M20 21.0001C19.713 17.269 16.7289 14.3151 12.995 14.0662L12 13.9999C11.6446 14.0096 11.3134 14.0225 11.0008 14.0378C7.3 14.2192 4.28417 17.3057 4 21.0001" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"></path><circle cx="12" cy="6.99988" r="4" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"></circle>
      </svg>
      <input id="helper-username" type="text" placeholder="johndoe" class="vt-input vt-pl-10" aria-describedby="helper-username-hint">
    </div>
    <p id="helper-username-hint" class="vt-field-description">Must be 3-20 characters, letters and numbers only</p>
  </div>
  <div class="vt-field">
    <label class="vt-label" for="helper-bio">Bio</label>
    <textarea id="helper-bio" rows="3" placeholder="Tell us about yourself..." class="vt-textarea" aria-describedby="helper-bio-hint"></textarea>
    <p id="helper-bio-hint" class="vt-field-description">Maximum 160 characters</p>
  </div>
</div>

Validation States

A status line under the field: an error on an invalid field, a confirmation on a valid one.

html

Please enter a valid email address

Username is available

<div class="vt-form vt-w-full vt-max-w-sm">
  <div class="vt-field">
    <label class="vt-label" for="valid-email">Email</label>
    <input id="valid-email" type="email" value="not-an-email" class="vt-input vt-input-error" aria-invalid="true" aria-describedby="valid-email-error">
    <p id="valid-email-error" class="vt-form-message vt-form-message-error">
      <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="none" aria-hidden="true">
        <circle cx="12" cy="12" r="10" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"></circle><path d="M12 8V12" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"></path><path d="M12.125 15.75H12M12.25 15.75C12.25 15.8881 12.1381 16 12 16C11.8619 16 11.75 15.8881 11.75 15.75C11.75 15.6119 11.8619 15.5 12 15.5C12.1381 15.5 12.25 15.6119 12.25 15.75Z" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"></path>
      </svg>
      Please enter a valid email address
    </p>
  </div>
  <div class="vt-field">
    <label class="vt-label" for="valid-username">Username</label>
    <input id="valid-username" type="text" value="johndoe" class="vt-input vt-input-success" aria-describedby="valid-username-status">
    <p id="valid-username-status" class="vt-form-message vt-form-message-success">
      <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="none" aria-hidden="true">
        <path d="M5 13.2592L7.58583 15.9568C8.2525 16.6523 8.58583 17 9.00004 17C9.41425 17 9.74759 16.6523 10.4143 15.9568L19 7" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"></path>
      </svg>
      Username is available
    </p>
  </div>
</div>

Compact Fields

A small label (vt-label vt-label-sm, 12px) over a small input (vt-input-sm) for dense panels and filter bars — the pair keeps the field's proportions.

html
<div class="vt-form-row vt-w-full vt-max-w-lg">
  <div class="vt-field">
    <label class="vt-label vt-label-sm" for="c-owner">Owner</label>
    <input id="c-owner" type="text" class="vt-input vt-input-sm" placeholder="Anyone">
  </div>
  <div class="vt-field">
    <label class="vt-label vt-label-sm" for="c-updated">Updated after</label>
    <input id="c-updated" type="date" class="vt-input vt-input-sm">
  </div>
</div>

Horizontal Layout

Label and input on the same row for settings-style forms.

html
<form class="vt-form vt-form-horizontal vt-w-full vt-max-w-lg" onsubmit="event.preventDefault()">
  <div class="vt-field">
    <label class="vt-label" for="h-name">Full name</label>
    <input id="h-name" type="text" value="John Doe" class="vt-input">
  </div>
  <div class="vt-field">
    <label class="vt-label" for="h-email">Email</label>
    <input id="h-email" type="email" value="john@example.com" class="vt-input">
  </div>
  <div class="vt-field">
    <label class="vt-label" for="h-website">Website</label>
    <input id="h-website" type="url" placeholder="https://" class="vt-input">
  </div>
  <div class="vt-form-actions">
    <button type="submit" class="vt-btn vt-btn-primary"><span>Save changes</span></button>
  </div>
</form>

Registration Form

Complete registration form with multiple field types.

html

Create account

Fill in your details to get started

Use 8+ characters with a mix of letters and numbers

<div class="vt-card vt-w-full vt-max-w-md">
  <div class="vt-card-header">
    <h3 class="vt-heading-sm">Create account</h3>
    <p>Fill in your details to get started</p>
  </div>
  <div class="vt-card-body">
    <form class="vt-form vt-w-full" onsubmit="event.preventDefault()">
      <div class="vt-form-row">
        <div class="vt-field">
          <label class="vt-label" for="reg-first-name">First name</label>
          <input type="text" id="reg-first-name" placeholder="John" class="vt-input">
        </div>
        <div class="vt-field">
          <label class="vt-label" for="reg-last-name">Last name</label>
          <input type="text" id="reg-last-name" placeholder="Doe" class="vt-input">
        </div>
      </div>
      <div class="vt-field">
        <label class="vt-label" for="reg-email">Email</label>
        <input type="email" id="reg-email" placeholder="you@example.com" class="vt-input" aria-describedby="reg-password-hint">
      </div>
      <div class="vt-field">
        <label class="vt-label" for="reg-password">Password</label>
        <input type="password" id="reg-password" placeholder="Min. 8 characters" class="vt-input" aria-describedby="reg-password-hint">
        <p id="reg-password-hint" class="vt-field-description">Use 8+ characters with a mix of letters and numbers</p>
      </div>
      <label class="vt-check-label" onclick="this.querySelector('.vt-checkbox').classList.toggle('checked')">
        <div class="vt-checkbox" role="checkbox" aria-checked="false"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="none" class="check-icon" aria-hidden="true">
            <path d="M5 13.2592L7.58583 15.9568C8.2525 16.6523 8.58583 17 9.00004 17C9.41425 17 9.74759 16.6523 10.4143 15.9568L19 7" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="3"></path>
          </svg></div>
        I agree to the Terms of Service
      </label>
      <div class="vt-form-actions vt-form-actions-block">
        <button type="submit" class="vt-btn vt-btn-primary"><span>Create account</span></button>
      </div>
    </form>
  </div>
</div>

Field

A label, a control and a hint or an error, stacked 8px apart. Mark a required field with the required attribute and say so in the label.

html

Shown in the sidebar and in invites

This URL is already taken

<div class="vt-form vt-w-full vt-max-w-sm">
  <div class="vt-field">
    <label class="vt-label" for="label-workspace">Workspace name</label>
    <input id="label-workspace" type="text" value="Acme" class="vt-input" aria-describedby="label-workspace-hint">
    <p id="label-workspace-hint" class="vt-field-description">Shown in the sidebar and in invites</p>
  </div>
  <div class="vt-field">
    <label class="vt-label" for="label-slug">URL</label>
    <input id="label-slug" type="text" value="acme" class="vt-input vt-input-error" aria-invalid="true" aria-describedby="label-slug-error">
    <p id="label-slug-error" class="vt-field-error">This URL is already taken</p>
  </div>
</div>
Class Type Description
vt-label Typography Field label (label, linked by for/id) — the Body/SM text style in the primary text color; see Typography
vt-field Layout Column of label, control and the line under it, 8px apart
vt-field-description Part Hint under the control — Body/SM, muted
vt-field-error Part Error under the control — Body/SM, in the error color, no icon

Guidelines

Do Pair every field with a visible label above the input.
Don't Don't use placeholder text as the only label.

Please enter a valid email address

Do Show errors inline with an icon and a clear message.
Don't Don't signal an error with color alone — add a message.

Anatomy

form.vt-form                                 ← Column of fields, 16px apart
├── div.vt-form-row                          ← Fields side by side (optional)
│   └── div.vt-field × 2
├── div.vt-field                             ← Field
│   ├── label.vt-label
│   ├── input.vt-input / textarea.vt-textarea
│   └── p.vt-field-description / p.vt-form-message  ← Hint or status
├── label.vt-check-label > .vt-checkbox      ← Consent (optional)
└── div.vt-form-actions                      ← Buttons, right-aligned
    └── button.vt-btn

API Reference

Class Type Description
vt-form Base Column of fields 16px apart; inline text (a consent line) in Body/SM
vt-form-row Layout Fields side by side in equal columns, 16px apart
vt-form-actions Part Row of buttons at the end of the form — right-aligned, 8px apart
vt-form-actions-block Modifier Buttons stretch across the row (a single full-width submit)
vt-form-horizontal Layout Labels in a 96px column, right-aligned beside their fields
vt-form-message Part Status line under a field — a 16px icon and Body/SM text
vt-form-message-error Variant Error status, in the error color
vt-form-message-success Variant Success status, in the success color
vt-field Component Field: label, control and description, 8px apart
vt-labelvt-label-sm Size A small label (Caption, 12px) for a compact field — beside vt-input-sm, in filter bars and dense panels (Typography)
vt-field-description Component Hint under a field
vt-inputvt-input-error/vt-input-success Component Text field and its error and success states (Input)
vt-check-label Component Checkbox with its text (Checkbox)

Accessibility

Feature Details
Labels Every input must have a visible label linked via for/id attributes
Errors Error messages linked via aria-describedby, invalid fields use aria-invalid="true"
Required Required fields should use required attribute and aria-required="true"
Groups Related fields wrapped in fieldset with legend element
Submit Form submission feedback should be announced to screen readers