Component

Phone Input

Phone number input components with country code selection and formatting

  • Component
  • Tailwind
  • MIT

Preview

Live component

Interactive preview
Open preview
9:41 100%
devsnips.dev/library/tailwind/components/input/phone-input/
fluid · no fixed width 100%
No dependencies Production-ready

Install

Add to your project

terminal
npx devsnips add Tailwind/Components/Input/phone-input
registry path: Tailwind/Components/Input/phone-input

Source

Implementation

code.html
<!-- Phone Input - Standard -->
<div>
  <label class="block text-sm font-medium text-gray-700 mb-1">Phone Number</label>
  <input type="tel" placeholder="(555) 123-4567" class="w-full px-4 py-3 bg-white border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition-colors" />
</div>

<!-- Phone Input - With Country Code -->
<div class="mt-4">
  <label class="block text-sm font-medium text-gray-700 mb-1">Mobile Number</label>
  <div class="flex">
    <select class="shrink-0 px-3 py-3 bg-gray-50 border border-gray-300 rounded-l-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500">
      <option>+1 🇺🇸</option>
      <option>+44 🇬🇧</option>
      <option>+91 🇮🇳</option>
      <option>+61 🇦🇺</option>
    </select>
    <input type="tel" placeholder="(555) 123-4567" class="flex-1 min-w-0 px-4 py-3 bg-white border border-gray-300 rounded-r-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition-colors" />
  </div>
</div>

<!-- Phone Input - Formatted -->
<div class="mt-4">
  <label class="block text-sm font-medium text-gray-700 mb-1">Contact Number</label>
  <div class="flex items-center flex-wrap gap-2">
    <input type="text" maxlength="3" placeholder="555" class="w-16 px-3 py-3 bg-white border border-gray-300 rounded-lg text-center focus:outline-none focus:ring-2 focus:ring-blue-500" />
    <span class="text-gray-400">-</span>
    <input type="text" maxlength="3" placeholder="123" class="w-16 px-3 py-3 bg-white border border-gray-300 rounded-lg text-center focus:outline-none focus:ring-2 focus:ring-blue-500" />
    <span class="text-gray-400">-</span>
    <input type="text" maxlength="4" placeholder="4567" class="w-20 px-3 py-3 bg-white border border-gray-300 rounded-lg text-center focus:outline-none focus:ring-2 focus:ring-blue-500" />
  </div>
</div>

<!-- Phone Input - WhatsApp Style -->
<div class="mt-4 p-4 bg-green-50 rounded-xl">
  <label class="block text-sm font-medium text-green-800 mb-2">WhatsApp / Mobile</label>
  <div class="flex gap-3">
    <div class="flex items-center gap-2 px-4 py-3 bg-white border border-green-200 rounded-lg">
      <span class="text-xl">🇺🇸</span>
      <span class="text-sm text-gray-600">US +1</span>
    </div>
    <input type="tel" placeholder="555 123 4567" class="flex-1 min-w-0 px-4 py-3 bg-white border border-green-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-green-500 focus:border-green-500 transition-colors" />
  </div>
</div>
43 lines UTF-8 · LF · Spaces: 2

AI-ready

Available to your agent.

This component is reachable through the DevSnips CLI, MCP server and Skills integrations — one registry, one resource path.

Resource path

devsnips://components/input/phone-input

Continue browsing

View all