v1.2.1

Input

Displays a form input field or a component that looks like an input field.

Default

html
<input type="email" placeholder="Email" class="vt-input" aria-label="Email">

With Label

html
<div class="vt-space-y-2">
  <label class="vt-label" for="input-2-1">
    Email
  </label>
  <input type="email" placeholder="Enter your email" class="vt-input" id="input-2-1">
</div>
<div class="vt-space-y-2">
  <label class="vt-label" for="input-2-2">
    Password
  </label>
  <input type="password" placeholder="Enter your password" class="vt-input" id="input-2-2">
</div>

With Description

Input with a helper text below.

html

This is your public display name.

<div class="vt-space-y-2">
  <label class="vt-label" for="input-3-1">
    Username
  </label>
  <input type="text" placeholder="@johndoe" class="vt-input" id="input-3-1" aria-describedby="input-3-2">
  <p class="vt-text-sm vt-text-foreground-muted" id="input-3-2">This is your public display name.</p>
</div>

With Icon

A leading icon: vt-input-icon before the input inside vt-input-group. The icon is decorative — the input keeps its own label.

html
<div class="vt-input-group">
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="none" class="vt-input-icon" aria-hidden="true">
    <path d="M17 17L21 21" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"></path><path d="M19 11C19 6.58172 15.4183 3 11 3C6.58172 3 3 6.58172 3 11C3 15.4183 6.58172 19 11 19C15.4183 19 19 15.4183 19 11Z" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"></path>
  </svg>
  <input type="search" placeholder="Search..." aria-label="Search" class="vt-input">
</div>
<div class="vt-input-group">
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="none" class="vt-input-icon" 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 type="email" placeholder="Email address" aria-label="Email address" class="vt-input">
</div>

Error State

html

Please enter a valid email address.

<div class="vt-field">
  <label class="vt-label" for="input-error-email">Email</label>
  <input type="email" value="invalid-email" aria-invalid="true" class="vt-input vt-input-error" id="input-error-email" aria-describedby="input-error-email-message">
  <p id="input-error-email-message" class="vt-field-error">Please enter a valid email address.</p>
</div>

Success State

Input whose value has been checked and is valid.

html

Username is available.

<div class="vt-field">
  <label class="vt-label" for="input-success-username">Username</label>
  <input type="text" value="johndoe" class="vt-input vt-input-success" id="input-success-username" aria-describedby="input-success-username-message">
  <p id="input-success-username-message" class="vt-field-success">Username is available.</p>
</div>

Disabled

html
<input type="email" placeholder="Email" disabled="" class="vt-input" aria-label="Email">

Form Example

html
<div class="vt-space-y-4">
  <div class="vt-space-y-2">
    <label class="vt-label" for="input-8-1">
      Email
    </label>
    <input type="email" placeholder="m@example.com" class="vt-input" id="input-8-1">
  </div>
  <div class="vt-space-y-2">
    <label class="vt-label" for="input-8-2">
      Password
    </label>
    <input type="password" placeholder="Enter password" class="vt-input" id="input-8-2">
  </div>
  <button class="vt-btn vt-btn-primary vt-w-full">
    Sign In
  </button>
</div>

Guidelines

Do
Always pair an input with a visible label.
Don't
Don't use placeholder text as a substitute for a label.

Please enter a valid email address.

Do
Pair the error state with a message below the field.
Don't
Don't mark a field invalid with a red border and no message.

API Reference

Class Type Description
vt-input Base Base input styles — height, padding, border, rounded, font, transition
vt-input-error State Red border for validation errors
vt-input-success State Green border and focus ring for a value confirmed valid
vt-field-error / vt-field-success Part The message under the field, in the error or success color
vt-label Base Label styles — font-size, font-weight, color
vt-input-icon Part A leading icon: an svg placed before the vt-input inside vt-input-group — 16px, muted, 12px in and centered; the input keeps 40px free at its start
vt-pl-10 / vt-pr-10 Legacy On a vt-input: 40px free at the start / end for an icon positioned with utilities — still works, prefer vt-input-icon
vt-input-group Part Wraps a vt-input and its leading vt-input-icon
disabled State HTML attribute — reduced opacity, no pointer events

Accessibility

Feature Details
Label Always associate a visible label via for/id or wrapping label element
Error Use aria-invalid="true" and aria-describedby pointing to error message
Success Color alone does not say the value is valid: link a success message with aria-describedby
Required Use required attribute and aria-required="true" for mandatory fields
Placeholder Placeholder is not a substitute for a label — always provide a label
Disabled Disabled inputs are excluded from tab order automatically