Phone Input
Not A Number
A phone field in its error state: the typed and the expected values sit side by side, so the missing digit shows and the input is never wiped.
- phone
- error
- validation
- compare
Preview
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/phoneinput-006?lang=en
Show the full instructions
What the link says, spelled out. Use it when your agent cannot open links — paste this text instead.
# Install and place "phoneinput-006" (Not A Number) 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/phoneinput-006.json
Registry item: https://vibeui.ru/r/phoneinput-006.json
Installs to: components/vibeui/phoneinput-006.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 in its error state: the typed and the expected values sit side by side, so the missing digit shows and the input is never wiped.
A phone field whose error shows the difference between what was typed and what is expected. Zero dependencies, one file, no client JS.
## 3. How to use it
import { Phoneinput006 } from "@/components/vibeui/phoneinput-006"
<Phoneinput006
label="Phone"
error="That does not look like a real number: ten digits are expected after +44."
defaultValue="+44 20 71"
example="+44 20 7123 4567"
/>
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-phoneinput-006-* palette — do not swap it for your theme tokens
- keeping the typed value: clearing the field on error forces a full retype
- the "typed / expected" comparison: a diagnosis without a sample never shows where the digit went missing
- aria-invalid as the single source of state — a parallel CSS class will drift out of sync sooner or later
- the monospace samples: in a proportional face the digits do not line up into a column
- the block's own light surface: without it the dark label disappears on a dark background
## 6. You may change
- the field name through label, the message through error, the typed value through defaultValue and the sample through example
- the normal focus color through accent
- the error colors through the --vibeui-phoneinput-006-error and --vibeui-phoneinput-006-error-soft variables
- the captions of the comparison rows
## 7. Rules
- The error is rendered up front: if it appears after submission, add role="alert" to the message or the screen reader stays silent.
- "Does not look like a real number" is softer than "invalid number" and does not accuse someone holding a rare but valid one.
- Do not validate on every keystroke: while typing, every number is unfinished and the error blinks for 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/phoneinput-006.jsonhttps://vibeui.ru/r/phoneinput-006.jsonКомпонент самодостаточен: один файл, без зависимостей, палитра в локальных переменных --vibeui-phoneinput-006-*. Серверный: из хуков только useId. Сообщение показывает разницу, а не диагноз: под текстом ошибки стоит сетка из двух строк — «набрано» и «нужно», — выровненная по базовой линии, поэтому цифры сравниваются взглядом сверху вниз. Оба образца набраны моноширинным. Состояние держится на aria-invalid у поля: от него красятся рамка, подпись (через :has() на корне) и обводка фокуса, отдельного класса нет. Введённое значение остаётся в поле — очистка поля при ошибке заставляет человека набирать всё заново и уходить с формы.
Component source
The same file your agent installs. Here in case you would rather copy it by hand.
import { useId } from "react"
import type { ComponentPropsWithoutRef, CSSProperties } from "react"
export type Phoneinput006Props = Omit<
ComponentPropsWithoutRef<"input">,
"children" | "type" | "size" | "defaultValue"
> & {
label?: string
error?: string
defaultValue?: string
example?: string
accent?: string
}
// Идея компонента: сообщение об ошибке показывает разницу, а не диагноз.
// Рядом стоят два образца — что набрано и что ожидается, — поэтому
// пропущенную цифру видно глазами. Введённое значение при этом остаётся
// в поле: очищать его при ошибке — самый быстрый способ заставить
// человека уйти с формы.
const STYLES = `
:where([data-vibeui-block="phoneinput-006"]){
--vibeui-phoneinput-006-surface:oklch(1 0 0);
--vibeui-phoneinput-006-surface-border:oklch(0.91 0.006 265);
--vibeui-phoneinput-006-fg:oklch(0.24 0.016 265);
--vibeui-phoneinput-006-muted:oklch(0.54 0.014 265);
--vibeui-phoneinput-006-field-border:oklch(0.85 0.01 265);
--vibeui-phoneinput-006-accent:oklch(0.55 0.2 262);
--vibeui-phoneinput-006-error:oklch(0.55 0.2 25);
--vibeui-phoneinput-006-error-soft:oklch(0.96 0.03 25);
--vibeui-phoneinput-006-radius:0.625rem;
--vibeui-phoneinput-006-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
--vibeui-phoneinput-006-mono:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,"Liberation Mono",monospace;
}
[data-vibeui-block="phoneinput-006"]{
box-sizing:border-box;width:100%;max-width:23rem;
padding:1rem;border-radius:0.875rem;
background:var(--vibeui-phoneinput-006-surface);
border:1px solid var(--vibeui-phoneinput-006-surface-border);
font-family:var(--vibeui-phoneinput-006-font);color:var(--vibeui-phoneinput-006-fg);
display:flex;flex-direction:column;gap:0.375rem;
}
[data-vibeui-block="phoneinput-006"] label{
font-size:0.875rem;font-weight:600;line-height:1.3;cursor:pointer;
transition:color .16s ease;
}
[data-vibeui-block="phoneinput-006"]:has(input[aria-invalid="true"]) label{
color:var(--vibeui-phoneinput-006-error);
}
[data-vibeui-block="phoneinput-006"] input{
box-sizing:border-box;width:100%;height:2.5rem;padding:0 0.75rem;
font:inherit;font-size:0.9375rem;font-variant-numeric:tabular-nums;
color:var(--vibeui-phoneinput-006-fg);
background:var(--vibeui-phoneinput-006-surface);
border:1px solid var(--vibeui-phoneinput-006-field-border);
border-radius:var(--vibeui-phoneinput-006-radius);
transition:border-color .16s ease,box-shadow .16s ease;
}
[data-vibeui-block="phoneinput-006"] input[aria-invalid="true"]{
border-color:var(--vibeui-phoneinput-006-error);
}
[data-vibeui-block="phoneinput-006"] input:focus-visible{
outline:none;border-color:var(--vibeui-phoneinput-006-accent);
box-shadow:0 0 0 3px color-mix(in oklab,var(--vibeui-phoneinput-006-accent) 22%,transparent);
}
[data-vibeui-block="phoneinput-006"] input[aria-invalid="true"]:focus-visible{
border-color:var(--vibeui-phoneinput-006-error);
box-shadow:0 0 0 3px color-mix(in oklab,var(--vibeui-phoneinput-006-error) 22%,transparent);
}
[data-vibeui-block="phoneinput-006"] [data-part="error"]{
margin:0;padding:0.5rem 0.625rem;border-radius:0.5rem;
background:var(--vibeui-phoneinput-006-error-soft);
font-size:0.8125rem;line-height:1.45;color:var(--vibeui-phoneinput-006-error);
display:flex;flex-direction:column;gap:0.375rem;
}
/* Две строки образцов выровнены в сетку: подписи «набрано» и «нужно»
стоят одна под другой, поэтому цифры сравниваются взглядом сверху вниз. */
[data-vibeui-block="phoneinput-006"] [data-part="compare"]{
display:grid;grid-template-columns:auto 1fr;gap:0.125rem 0.5rem;
align-items:baseline;
}
[data-vibeui-block="phoneinput-006"] [data-part="key"]{
font-size:0.75rem;color:var(--vibeui-phoneinput-006-muted);
}
[data-vibeui-block="phoneinput-006"] samp{
font-family:var(--vibeui-phoneinput-006-mono);font-size:0.8125rem;
color:var(--vibeui-phoneinput-006-fg);
}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="phoneinput-006"] *{animation:none!important;transition:none!important}}
`
/**
* Телефон в состоянии ошибки: рядом показаны набранное и ожидаемое, а
* введённое значение не стирается. Один файл, ноль зависимостей.
*/
export function Phoneinput006({
label = "Телефон",
error = "Номер не похож на настоящий: после кода +7 должно быть десять цифр, а набрано семь.",
defaultValue = "+7 999 12-34",
example = "+7 999 123-45-67",
accent,
className,
style,
...props
}: Phoneinput006Props) {
const id = useId()
const errorId = `${id}-error`
const palette = {
...(accent ? { "--vibeui-phoneinput-006-accent": accent } : null),
...style,
} as CSSProperties
return (
<>
<style href="vibeui-phoneinput-006" precedence="medium">
{STYLES}
</style>
<div
data-vibeui-block="phoneinput-006"
className={className}
style={palette}
>
<label htmlFor={id}>{label}</label>
<input
{...props}
id={id}
name="phone"
type="tel"
inputMode="tel"
autoComplete="tel"
defaultValue={defaultValue}
aria-invalid="true"
aria-describedby={errorId}
/>
<div data-part="error" id={errorId}>
<span>{error}</span>
<span data-part="compare">
<span data-part="key">набрано</span>
<samp>{defaultValue}</samp>
<span data-part="key">нужно</span>
<samp>{example}</samp>
</span>
</div>
</div>
</>
)
}