Component
Character Count Input
Input fields with character counters, limits, and progress indicators
- Component
- Tailwind
- MIT
Preview
Live component
9:41 100%
devsnips.dev/library/tailwind/components/input/character-count/ fluid · no fixed width 100%
Install
Add to your project
npx devsnips add Tailwind/Components/Input/character-count Tailwind/Components/Input/character-count <!-- Character Count - Standard -->
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Tweet</label>
<textarea rows="3" maxlength="280" placeholder="What's happening?" class="w-full px-4 py-3 bg-white border border-gray-300 rounded-xl focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition-colors resize-none"></textarea>
<div class="mt-1 flex justify-between text-xs">
<span class="text-gray-500">Minimum 10 characters</span>
<span class="text-gray-400"><span class="count">0</span>/280</span>
</div>
</div>
<!-- Character Count - Warning State -->
<div class="mt-6">
<label class="block text-sm font-medium text-gray-700 mb-1">Title</label>
<textarea rows="2" maxlength="50" placeholder="Enter a title..." class="w-full px-4 py-3 bg-amber-50 border border-amber-300 rounded-xl focus:outline-none focus:ring-2 focus:ring-amber-500 focus:border-amber-500 transition-colors resize-none"></textarea>
<div class="mt-1 flex justify-between text-xs">
<span class="text-amber-600">Title should be descriptive</span>
<span class="text-amber-500"><span class="count">35</span>/50 remaining</span>
</div>
</div>
<!-- Character Count - Tags Input -->
<div class="mt-6">
<label class="block text-sm font-medium text-gray-700 mb-1">Tags</label>
<div class="flex flex-wrap gap-2 p-3 bg-white border border-gray-300 rounded-xl focus-within:ring-2 focus-within:ring-blue-500 focus-within:border-blue-500 transition-colors">
<span class="px-2 py-1 bg-blue-100 text-blue-700 text-sm rounded-md flex items-center gap-1">
javascript
<button class="hover:text-blue-900">
<svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
</svg>
</button>
</span>
<span class="px-2 py-1 bg-purple-100 text-purple-700 text-sm rounded-md flex items-center gap-1">
tailwind
<button class="hover:text-purple-900">
<svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
</svg>
</button>
</span>
<input type="text" placeholder="Add tag..." class="flex-1 min-w-[100px] bg-transparent border-0 focus:outline-none text-sm" />
</div>
<p class="mt-1 text-xs text-gray-500">Press Enter to add. Maximum 5 tags.</p>
</div>
<!-- Character Count - Progress Bar -->
<div class="mt-6">
<label class="block text-sm font-medium text-gray-700 mb-1">Project Description</label>
<textarea rows="3" maxlength="200" placeholder="Describe your project..." class="w-full px-4 py-3 bg-white border border-gray-300 rounded-xl focus:outline-none focus:ring-2 focus:ring-green-500 focus:border-green-500 transition-colors resize-none"></textarea>
<div class="mt-2 w-full bg-gray-200 rounded-full h-1.5">
<div class="bg-green-500 h-1.5 rounded-full transition-all" style="width: 45%"></div>
</div>
<p class="mt-1 text-xs text-gray-500 text-center">90/200 characters used</p>
</div> # Character Count
Input with character counter.
## Usage
```bash
npx devsnips add Tailwind/Components/Input/character-count
```
Copy from `code.html`.
## File Structure
`code.html` · `preview.html` · `metadata.json` · `README.md` 54 lines UTF-8 · LF · Spaces: 2
Continue browsing