Inputs
Phone Field
A phone field masked from digits: pasting any format keeps working, and deleting never sticks on a bracket.
- input
- phone
- mask
- form
Preview
1440pxHost theme
Use it with AI
- 1. Copy the link.
- 2. Write to your agent in your own words and drop the link into the sentence.
- 3. The agent opens the link and installs the component from the registry.
put this in the header: https://vibeui.ru/c/input-005?lang=en
+44
We will text you a confirmation codeShow the full instructions
What the link says, spelled out. Use it when your agent cannot open links — paste this text instead.
# Install and place "input-005" (Phone Field) from VibeUI
## 1. Install first — do not skip, do not recreate
Run this exact command before writing any code:
npx shadcn@latest add https://vibeui.ru/r/input-005.json
Registry item: https://vibeui.ru/r/input-005.json
Installs to: components/vibeui/input-005.tsx (the exact path follows this project's components.json aliases).
npm dependencies: none.
Registry dependencies: none.
Install it from the registry. Do not recreate it from the description,
do not substitute a similar component from another library, and do not
rewrite it to match the project's existing style.
## 2. What it is
A phone field masked from digits: pasting any format keeps working, and deleting never sticks on a bracket.
A phone field: the country code beside the input, a mask drawn over the digits and paste-any-format support. onChange returns digits only. Zero dependencies, one file.
## 3. How to use it
import { Input005 } from "@/components/vibeui/input-005"
<Input005 prefix="+44" onChange={(digits) => setPhone(digits)} />
Read the installed file for the full prop list.
## 4. Where to place it
This is a small inline component. Put it exactly where the user asked,
inside the existing markup. Do not create a new page, section or
wrapper for it. If a similar control already sits in that spot,
replace it instead of adding a second one.
Placement: ___
(The user fills this line in. If it is still blank, ask where to put it
instead of guessing.)
## 5. Keep exactly as installed
- the local --vibeui-input-005-* palette — do not swap it for your theme tokens
- storing digits only: the mask is presentation, not the value
- the country code outside the input — it must not be deleted by accident
- inputMode="tel": that is the numeric keypad on a phone
- tabular figures so the number does not jitter while typing
- emitting raw digits in onChange rather than the formatted string
## 6. You may change
- prefix — the country code
- the mask format for your country
- label and hint
- the accent through the accent prop
## 7. Rules
- The mask assumes ten digits: other countries need a different format.
- Do not fold the country code into the value: assemble the full number on submit.
- Validation belongs on the server: mask length guarantees nothing.
- Do not lift the CSS variables into globals.css: the component has to stay a single file.
## 8. Verify
- it renders with no console errors;
- it looks like the preview on the VibeUI page you copied this from;
- if it does not, you changed something listed in section 5 — put it back.For developers
npx shadcn@latest add https://vibeui.ru/r/input-005.jsonhttps://vibeui.ru/r/input-005.jsonКомпонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-input-005-*. Клиентский: "use client". В состоянии живут только цифры, скобки и дефисы дорисовываются функцией форматирования — поэтому любой формат вставки даёт один результат. Код страны вынесен из поля отдельным элементом, чтобы его не стирали.
Component source
The same file your agent installs. Here in case you would rather copy it by hand.
"use client"
import { useId, useState } from "react"
import type { ComponentPropsWithoutRef, CSSProperties } from "react"
export type Input005Props = Omit<
ComponentPropsWithoutRef<"div">,
"children" | "onChange"
> & {
label?: string
prefix?: string
hint?: string
onChange?: (digits: string) => void
accent?: string
}
// Идея компонента: телефон с маской, которая не мешает. Форматирование идёт
// от цифр: из ввода вынимаются только они, а скобки и дефисы дорисовываются
// сверху. Так вставка из буфера в любом формате не ломает поле, а стирание
// не застревает на скобке.
const STYLES = `
:where([data-vibeui-block="input-005"]){
--vibeui-input-005-bg:oklch(1 0 0);
--vibeui-input-005-fg:oklch(0.22 0.014 265);
--vibeui-input-005-muted:oklch(0.56 0.014 265);
--vibeui-input-005-border:oklch(0.9 0.006 265);
--vibeui-input-005-field:oklch(0.985 0.002 265);
--vibeui-input-005-accent:oklch(0.55 0.17 265);
--vibeui-input-005-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="input-005"]{
display:flex;flex-direction:column;gap:0.375rem;
width:100%;max-width:20rem;box-sizing:border-box;padding:0.875rem;
background:var(--vibeui-input-005-bg);
border:1px solid var(--vibeui-input-005-border);border-radius:0.875rem;
font-family:var(--vibeui-input-005-font);color:var(--vibeui-input-005-fg);
}
[data-vibeui-block="input-005"] label{font-size:0.8125rem;font-weight:600}
[data-vibeui-block="input-005"] [data-part="row"]{
display:flex;align-items:center;gap:0.5rem;
box-sizing:border-box;height:2.5rem;padding:0 0.75rem;
border:1px solid var(--vibeui-input-005-border);border-radius:0.625rem;
background:var(--vibeui-input-005-field);
}
[data-vibeui-block="input-005"] [data-part="row"]:focus-within{
outline:2px solid var(--vibeui-input-005-accent);outline-offset:1px;border-color:transparent;
}
/* Код страны — не часть поля: его не стирают и не редактируют случайно. */
[data-vibeui-block="input-005"] [data-part="prefix"]{
flex:none;color:var(--vibeui-input-005-muted);font-size:0.875rem;font-variant-numeric:tabular-nums;
}
[data-vibeui-block="input-005"] input{
flex:1;min-width:0;height:100%;border:0;background:transparent;color:inherit;
font:inherit;font-size:0.875rem;font-variant-numeric:tabular-nums;letter-spacing:0.01em;
}
[data-vibeui-block="input-005"] input:focus{outline:none}
[data-vibeui-block="input-005"] [data-part="hint"]{font-size:0.75rem;line-height:1.4;color:var(--vibeui-input-005-muted)}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="input-005"] *{animation:none!important;transition:none!important}}
`
// Форматирование идёт от цифр: вставка «+7 (999) 000-00-00» и «79990000000»
// даёт одинаковый результат, а стирание не застревает на скобке.
function format(digits: string) {
const value = digits.slice(0, 10)
const parts = [
value.slice(0, 3),
value.slice(3, 6),
value.slice(6, 8),
value.slice(8, 10),
].filter(Boolean)
if (parts.length === 0) return ""
if (parts.length === 1) return `(${parts[0]}`
return `(${parts[0]}) ${parts.slice(1).join("-")}`
}
/**
* Телефон с маской от цифр: вставка в любом формате не ломает поле.
* Один файл, ноль зависимостей, собственная палитра.
*/
export function Input005({
label = "Телефон",
prefix = "+7",
hint = "Пришлём код подтверждения в СМС",
onChange,
accent,
className,
style,
...props
}: Input005Props) {
const id = useId()
const [digits, setDigits] = useState("9990000000")
const palette = {
...(accent ? { "--vibeui-input-005-accent": accent } : null),
...style,
} as CSSProperties
return (
<>
<style href="vibeui-input-005" precedence="medium">
{STYLES}
</style>
<div
{...props}
data-vibeui-block="input-005"
className={className}
style={palette}
>
<label htmlFor={id}>{label}</label>
<div data-part="row">
<span data-part="prefix">{prefix}</span>
<input
id={id}
type="tel"
inputMode="tel"
autoComplete="tel-national"
placeholder="(999) 000-00-00"
value={format(digits)}
aria-describedby={hint ? `${id}-hint` : undefined}
onChange={(event) => {
const next = event.target.value.replace(/\D/g, "").slice(0, 10)
setDigits(next)
onChange?.(next)
}}
/>
</div>
{hint ? (
<span data-part="hint" id={`${id}-hint`}>
{hint}
</span>
) : null}
</div>
</>
)
}