Skip to content

Input

Text inputs allow users to enter and edit text. They are one of the most fundamental form elements.

Usage

Use inputs for single-line text entry. For longer content, consider using a textarea instead.

Basic Input

html
<input type="text" class="df-input" placeholder="Enter your name">

With Label

Always associate inputs with labels for accessibility.

html
<label class="df-label" for="email-input">Email Address</label>
<input type="email" id="email-input" class="df-input" placeholder="you@example.com">

Sizes

Inputs come in three sizes: small, medium (default), and large.

html
<input type="text" class="df-input df-input--sm" placeholder="Small">
<input type="text" class="df-input" placeholder="Medium">
<input type="text" class="df-input df-input--lg" placeholder="Large">

States

Disabled

html
<input type="text" class="df-input" placeholder="Disabled input" disabled>

Read-only

html
<input type="text" class="df-input" value="Read-only value" readonly>

Error State

Please enter a valid email address
html
<input type="text" class="df-input df-input--error" value="Invalid value">
<span class="df-input-error">Please enter a valid email address</span>

Success State

html
<input type="text" class="df-input df-input--success" value="Valid input">

With Icons

html
<div class="df-input-group">
  <span class="df-input-icon">
    <svg><!-- search icon --></svg>
  </span>
  <input type="text" class="df-input df-input--with-icon" placeholder="Search...">
</div>

Input Types

Helper Text

Must be at least 8 characters
html
<label class="df-label" for="password-input">Password</label>
<input type="password" id="password-input" class="df-input">
<span class="df-input-helper">Must be at least 8 characters</span>

Accessibility

  • Always use <label> elements with inputs
  • Use aria-describedby to link helper/error text
  • Provide clear error messages
  • Ensure sufficient color contrast
  • Support keyboard navigation

Best Practices

  • Use appropriate input types (email, tel, url) for better mobile keyboards
  • Provide placeholder text as a hint, not a replacement for labels
  • Show validation feedback inline, near the input
  • Mark required fields clearly

API Reference

Classes

ClassDescription
df-inputBase input class (required)
df-input--smSmall size
df-input--lgLarge size
df-input--errorError state
df-input--successSuccess state
df-input--with-iconInput with left icon
df-input--with-icon-rightInput with right icon

CSS Custom Properties

PropertyDefaultDescription
--df-input-padding-x0.875remHorizontal padding
--df-input-padding-y0.625remVertical padding
--df-input-font-size0.875remFont size
--df-input-radius0.375remBorder radius
--df-input-border-colorvar(--df-gray-300)Border color
--df-input-focus-ringvar(--df-primary)Focus ring color

Built with care by Everforth