Input
A basic widget for getting the user input is a text field. Keyboard and mouse can be used for providing or changing data.
Basic
Basic input example.
<div class="flex flex-col gap-3">
<input type="text" class="py-3 px-4 block w-full border-gray-200 rounded-md text-sm focus:border-hs2-primary focus:ring-hs2-primary dark:bg-slate-900 dark:border-gray-700 dark:text-gray-400">
<textarea class="py-3 px-4 block w-full border-gray-200 rounded-md text-sm focus:border-hs2-primary focus:ring-hs2-primary dark:bg-slate-900 dark:border-gray-700 dark:text-gray-400" rows="3"></textarea>
</div>
Placeholder
Basic input example with placeholder.
<div class="flex flex-col gap-3">
<input type="text" class="py-3 px-4 block w-full border-gray-200 rounded-md text-sm focus:border-hs2-primary focus:ring-hs2-primary dark:bg-slate-900 dark:border-gray-700 dark:text-gray-400" placeholder="This is placeholder">
<textarea class="py-3 px-4 block w-full border-gray-200 rounded-md text-sm focus:border-hs2-primary focus:ring-hs2-primary dark:bg-slate-900 dark:border-gray-700 dark:text-gray-400" rows="3" placeholder="This is a textarea placeholder"></textarea>
</div>
Sizes
Inputs stacked small to large sizes.
<div class="flex flex-col gap-3">
<input type="text" class="py-2 px-3 block w-full border-gray-200 rounded-md text-sm focus:border-hs2-primary focus:ring-hs2-primary dark:bg-slate-900 dark:border-gray-700 dark:text-gray-400" placeholder="Small size">
<input type="text" class="py-3 px-4 block w-full border-gray-200 rounded-md text-sm focus:border-hs2-primary focus:ring-hs2-primary dark:bg-slate-900 dark:border-gray-700 dark:text-gray-400" placeholder="Default size">
<input type="text" class="py-3 px-4 block w-full border-gray-200 rounded-md text-sm focus:border-hs2-primary focus:ring-hs2-primary dark:bg-slate-900 dark:border-gray-700 dark:text-gray-400 sm:p-5" placeholder="Large size">
</div>
Pilled input
Use the .rounded-full
utility class to make inputs circular.
<input type="text" class="py-3 px-5 block w-full border-gray-200 rounded-full text-sm focus:border-hs2-primary focus:ring-hs2-primary dark:bg-slate-900 dark:border-gray-700 dark:text-gray-400" placeholder="Input text">
Readonly
Add the readonly
boolean attribute on an input to prevent modification of the input's value.
<input type="text" class="py-3 px-4 block w-full border-gray-200 rounded-md text-sm focus:border-hs2-primary focus:ring-hs2-primary dark:bg-slate-900 dark:border-gray-700 dark:text-gray-400" placeholder="Readonly input" readonly>
Disabled
Disabled input.
<div class="flex flex-col gap-3">
<input type="text" class="opacity-70 pointer-events-none py-3 px-4 block w-full bg-gray-50 border-gray-200 rounded-md text-sm focus:border-blue-500 focus:ring-blue-500 dark:bg-slate-900 dark:border-gray-700 dark:text-gray-400" placeholder="Disabled input" disabled>
<input type="text" class="opacity-70 pointer-events-none py-3 px-4 block w-full bg-gray-50 border-gray-200 rounded-md text-sm focus:border-blue-500 focus:ring-blue-500 dark:bg-slate-900 dark:border-gray-700 dark:text-gray-400" placeholder="Disabled readonly input" disabled readonly>
</div>
Label
Basic input example with label.
<label for="input-label" class="block text-sm font-medium mb-2 dark:text-white">Email</label>
<input type="email" id="input-label" class="py-3 px-4 block w-full border-gray-200 rounded-md text-sm focus:border-hs2-primary focus:ring-hs2-primary dark:bg-slate-900 dark:border-gray-700 dark:text-gray-400" placeholder="you@site.com">
Hidden label
<label>
elements hidden using the .sr-only
class
Helper text
Basic input example with helper text.
<div class="sm:inline-flex sm:items-center space-y-2 sm:space-y-0 sm:space-x-3 w-full">
<label for="inline-input-label-with-helper-text" class="block text-sm font-medium mb-2 dark:text-white">Email</label>
<input type="email" id="inline-input-label-with-helper-text" class="py-3 px-4 block w-full border-gray-200 rounded-md text-sm focus:border-hs2-primary focus:ring-hs2-primary dark:bg-slate-900 dark:border-gray-700 dark:text-gray-400" placeholder="you@site.com" aria-describedby="hs-inline-input-helper-text">
<p class="text-sm text-gray-500 mt-2" id="hs-inline-input-helper-text">We'll never share your details.</p>
</div>
Inline helper text
Basic input example with inline helper text.
<div class="sm:inline-flex sm:items-center space-y-2 sm:space-y-0 sm:space-x-3 w-full">
<label for="inline-input-label-with-helper-text" class="block text-sm font-medium mb-2 dark:text-white">Email</label>
<input type="email" id="inline-input-label-with-helper-text" class="py-3 px-4 block w-full border-gray-200 rounded-md text-sm focus:border-hs2-primary focus:ring-hs2-primary dark:bg-slate-900 dark:border-gray-700 dark:text-gray-400" placeholder="you@site.com" aria-describedby="hs-inline-input-helper-text">
<p class="text-sm text-gray-500 mt-2" id="hs-inline-input-helper-text">We'll never share your details.</p>
</div>
Corner hint
Basic input example with corner-hint.
<div class="flex justify-between items-center">
<label for="with-corner-hint" class="block text-sm font-medium mb-2 dark:text-white">Email</label>
<span class="block text-sm text-gray-500 mb-2">Optional</span>
</div>
<input type="email" id="with-corner-hint" class="py-3 px-4 block w-full border-gray-200 rounded-md text-sm focus:border-hs2-primary focus:ring-hs2-primary dark:bg-slate-900 dark:border-gray-700 dark:text-gray-400" placeholder="you@site.com">
Validation states
It provides valuable, actionable feedback to your users with HTML5 form validation.
<div class="flex flex-col gap-4">
<div>
<label for="hs-validation-name-error" class="block text-sm font-medium mb-2 dark:text-white">Email</label>
<div class="relative">
<input type="text" id="hs-validation-name-error" name="hs-validation-name-error" class="py-3 px-4 block w-full border-hs2-danger rounded-md text-sm focus:border-hs2-danger focus:ring-hs2-danger dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400" required aria-describedby="hs-validation-name-error-helper">
<div class="absolute inset-y-0 right-0 flex items-center pointer-events-none pr-3">
<svg class="h-5 w-5 text-hs2-danger" width="16" height="16" fill="currentColor" viewBox="0 0 16 16" aria-hidden="true">
<path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zM8 4a.905.905 0 0 0-.9.995l.35 3.507a.552.552 0 0 0 1.1 0l.35-3.507A.905.905 0 0 0 8 4zm.002 6a1 1 0 1 0 0 2 1 1 0 0 0 0-2z" />
</svg>
</div>
</div>
<p class="text-sm text-hs2-danger mt-2" id="hs-validation-name-error-helper">Please enter a valid email address.</p>
</div>
<div>
<label for="hs-validation-name-success" class="block text-sm font-medium mb-2 dark:text-white">Email</label>
<div class="relative">
<input type="text" id="hs-validation-name-success" name="hs-validation-name-success" class="py-3 px-4 block w-full border-hs2-success rounded-md text-sm focus:border-hs2-success focus:ring-hs2-success dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400" required aria-describedby="hs-validation-name-success-helper">
<div class="absolute inset-y-0 right-0 flex items-center pointer-events-none pr-3">
<svg class="h-5 w-5 text-hs2-success" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16">
<path d="M12.736 3.97a.733.733 0 0 1 1.047 0c.286.289.29.756.01 1.05L7.88 12.01a.733.733 0 0 1-1.065.02L3.217 8.384a.757.757 0 0 1 0-1.06.733.733 0 0 1 1.047 0l3.052 3.093 5.4-6.425a.247.247 0 0 1 .02-.022Z" />
</svg>
</div>
</div>
<p class="text-sm text-hs2-success mt-2" id="hs-validation-name-success-helper">Looks good!</p>
</div>
</div>