Telephone Input

Telephone-number input.

html

<label class="ti" for="ti-1">
  <span class="ti__label">Phone number</span>
  <input class="ti__input" id="ti-1" type="tel" placeholder="+44 20 7946 0958" autocomplete="tel" inputmode="tel" style="--accent:#BFD9F2;" aria-describedby="ti-hint-1">
  <span class="ti__hint" id="ti-hint-1">Format: +[country] [number]</span>
</label>
<style>
.ti { display: block; font: 14px system-ui, sans-serif; color: #241430; max-width: 260px; }
.ti__label { display: block; margin-bottom: 6px; font-weight: 500; }
.ti__req { color: #241430; }
.ti__input { width: 100%; box-sizing: border-box; padding: 10px 12px; font: inherit; color: #241430; background: #FAF7F2; border: 1.5px solid #24143040; border-radius: 8px; }
.ti__input:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); }
.ti__hint { display: block; margin-top: 6px; font-size: 11px; color: #24143080; }
</style>

tailwind

<label class="block max-w-[260px] font-sans text-sm text-[#241430]" for="ti-tw-1">
  <span class="block mb-1.5 font-medium">Phone number</span>
  <input id="ti-tw-1" type="tel" placeholder="+44 20 7946 0958" autocomplete="tel" inputmode="tel" aria-describedby="ti-tw-hint-1"
    class="w-full box-border px-3 py-2.5 bg-[#FAF7F2] border-[1.5px] border-[#24143040] rounded-lg focus-visible:outline-none" style="border-color:#BFD9F2;">
  <span id="ti-tw-hint-1" class="block mt-1.5 text-[11px] text-[#24143080]">Format: +[country] [number]</span>
</label>

react

export function TelephoneInput({
  label = "Phone number",
  placeholder = "+44 20 7946 0958",
  pattern = "+[country] [number]",
  accent = "#BFD9F2",
  required = false,
}) {
  return (
    <label style={{ display: "block", maxWidth: 260, fontFamily: "system-ui, sans-serif", fontSize: 14, color: "#241430" }}>
      <span style={{ display: "block", marginBottom: 6, fontWeight: 500 }}>{label}{required && " *"}</span>
      <input type="tel" placeholder={placeholder} autoComplete="tel" inputMode="tel" required={required} aria-describedby="ti-react-hint-1" style={{
        width: "100%", boxSizing: "border-box", padding: "10px 12px", font: "inherit", color: "#241430",
        background: "#FAF7F2", border: `1.5px solid ${accent}`, borderRadius: 8,
      }} />
      <span id="ti-react-hint-1" style={{ display: "block", marginTop: 6, fontSize: 11, color: "#24143080" }}>Format: {pattern}</span>
    </label>
  );
}