Inputs

Grouped Error

A date split into three fields with a single shared error: February 31st is wrong as a whole, so the message lives on the fieldset, not under one field.

  • field
  • fieldset
  • error
  • date

Preview

1440pxHost theme

Use it with AI

  1. 1. Copy the link.
  2. 2. Write to your agent in your own words and drop the link into the sentence.
  3. 3. The agent opens the link and installs the component from the registry.

put this in the header: https://vibeui.ru/c/field-010?lang=en

Date of birth
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 "field-010" (Grouped Error) 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/field-010.json

Registry item: https://vibeui.ru/r/field-010.json
Installs to: components/vibeui/field-010.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 date split into three fields with a single shared error: February 31st is wrong as a whole, so the message lives on the fieldset, not under one field.

A date split across three fields with one error for the whole group. The message is tied to the fieldset through aria-describedby, so it is announced on entering any of the three, and all three borders turn red — the date is wrong as a whole. A server component, zero dependencies, one file, its own palette.

## 3. How to use it
import { Field010 } from "@/components/vibeui/field-010"

<Field010
  name="birth"
  legend="Date of birth"
  error="February 31st does not exist — check the day and the month."
/>

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-field-010-* palette — do not swap it for your theme tokens (bg-background, border-input and the like)
- a real <fieldset> with a <legend>: a group of fields must be a group in the markup too, otherwise three fields read as three unrelated rows
- the message on the group rather than under one field — the error is about the combination of values
- aria-describedby on the fieldset together with role="alert" on the message: that is what makes it audible from any of the three fields
- highlighting all three borders at once: highlighting one would lie about which value is wrong
- min-inline-size:0 on the fieldset — without it, it refuses to shrink in a narrow column
- the "!" mark beside the message: red is not visible to everyone

## 6. You may change
- the legend group heading and the error text
- the hint that occupies the error slot while there is no error
- the makeup of the group: any fields validated together instead of day, month and year
- the accent through the accent prop
- the name prop: every field id in the group is built from it

## 7. Rules
- Validation belongs to the caller: the component displays the error, it does not compute it.
- Do not repeat the shared message under each field — three identical lines get read aloud three times.
- If the error is about one value, show it under that field: a group-level error is only for combinations.
- 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/field-010.json
https://vibeui.ru/r/field-010.json

Компонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-field-010-*. Серверный: состояния нет. Группа объявлена настоящим <fieldset> с <legend>, сообщение связано с ней через aria-describedby и role="alert", поэтому его слышно при входе в любое из трёх полей. Ошибка поднимает data-invalid на корне и красит рамки всех полей группы, а не одного. У fieldset сброшен min-inline-size, иначе он не сжимается.

Component source

The same file your agent installs. Here in case you would rather copy it by hand.

import type { ComponentPropsWithoutRef, CSSProperties } from "react"

export type Field010Props = Omit<
  ComponentPropsWithoutRef<"div">,
  "children" | "defaultValue"
> & {
  legend?: string
  error?: string
  hint?: string
  name?: string
  accent?: string
}

// Идея компонента: несколько полей — одна ошибка. Дата, разбитая на день,
// месяц и год, ломается целиком: «31 февраля» неверно, хотя каждое поле по
// отдельности заполнено правильно. Поэтому сообщение живёт на группе, а не
// под одним из полей, группа объявлена <fieldset> с <legend>, и ошибка
// связана с ней через aria-describedby — вслух её слышно при входе в любое поле.
const STYLES = `
:where([data-vibeui-block="field-010"]){
--vibeui-field-010-bg:oklch(1 0 0);
--vibeui-field-010-surface:oklch(1 0 0);
--vibeui-field-010-fg:oklch(0.24 0.014 265);
--vibeui-field-010-muted:oklch(0.55 0.014 265);
--vibeui-field-010-border:oklch(0.88 0.008 265);
--vibeui-field-010-shell:oklch(0.91 0.006 265);
--vibeui-field-010-accent:oklch(0.55 0.2 262);
--vibeui-field-010-danger:oklch(0.55 0.19 25);
--vibeui-field-010-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
/* Своя светлая подложка: группу показывают поверх любого фона. */
[data-vibeui-block="field-010"]{
width:100%;max-width:23rem;box-sizing:border-box;padding:0.875rem;
background:var(--vibeui-field-010-surface);
border:1px solid var(--vibeui-field-010-shell);border-radius:0.875rem;
font-family:var(--vibeui-field-010-font);color:var(--vibeui-field-010-fg);
}
[data-vibeui-block="field-010"] *{box-sizing:border-box}
/* Настоящий fieldset: min-inline-size сбрасываем, иначе он не сжимается. */
[data-vibeui-block="field-010"] fieldset{
margin:0;padding:0;border:0;min-inline-size:0;
}
[data-vibeui-block="field-010"] legend{
padding:0;margin-bottom:0.5rem;
font-size:0.8125rem;font-weight:650;
}
[data-vibeui-block="field-010"] [data-part="row"]{
display:flex;align-items:flex-end;gap:0.5rem;
}
[data-vibeui-block="field-010"] [data-part="cell"]{
display:flex;flex-direction:column;gap:0.25rem;min-width:0;
}
[data-vibeui-block="field-010"] [data-part="cell"][data-size="day"]{flex:1 1 3.5rem}
[data-vibeui-block="field-010"] [data-part="cell"][data-size="month"]{flex:1.6 1 6rem}
[data-vibeui-block="field-010"] [data-part="cell"][data-size="year"]{flex:1.1 1 4.5rem}
[data-vibeui-block="field-010"] [data-part="cell"] label{
font-size:0.6875rem;font-weight:600;color:var(--vibeui-field-010-muted);
}
[data-vibeui-block="field-010"] :is(input,select){
width:100%;height:2.375rem;padding:0 0.5rem;
background:var(--vibeui-field-010-bg);color:inherit;
border:1px solid var(--vibeui-field-010-border);border-radius:0.625rem;
font:inherit;font-size:0.875rem;
}
[data-vibeui-block="field-010"] input{font-variant-numeric:tabular-nums;text-align:center}
[data-vibeui-block="field-010"] :is(input,select):focus-visible{
outline:2px solid var(--vibeui-field-010-accent);outline-offset:1px;
border-color:var(--vibeui-field-010-accent);
}
[data-vibeui-block="field-010"] input::-webkit-outer-spin-button,
[data-vibeui-block="field-010"] input::-webkit-inner-spin-button{appearance:none;margin:0}
/* Ошибка красит всю группу: неверна дата целиком, а не одно из трёх полей. */
[data-vibeui-block="field-010"][data-invalid="true"] :is(input,select){
border-color:color-mix(in oklab,var(--vibeui-field-010-danger) 55%,var(--vibeui-field-010-border));
}
[data-vibeui-block="field-010"][data-invalid="true"] :is(input,select):focus-visible{outline-color:var(--vibeui-field-010-danger)}
[data-vibeui-block="field-010"] [data-part="note"]{
margin:0.5rem 0 0;font-size:0.75rem;line-height:1.4;color:var(--vibeui-field-010-muted);
}
[data-vibeui-block="field-010"] [data-part="error"]{
display:flex;align-items:flex-start;gap:0.375rem;margin:0.5rem 0 0;
padding:0.4375rem 0.5rem;border-radius:0.5rem;
background:color-mix(in oklab,var(--vibeui-field-010-danger) 8%,oklch(1 0 0));
font-size:0.75rem;line-height:1.4;font-weight:600;
color:var(--vibeui-field-010-danger);
}
[data-vibeui-block="field-010"] [data-part="mark"]{
flex:none;display:inline-flex;align-items:center;justify-content:center;
width:0.875rem;height:0.875rem;margin-top:0.0625rem;border-radius:9999px;
background:var(--vibeui-field-010-danger);color:oklch(1 0 0);
font-size:0.625rem;font-weight:700;line-height:1;
}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="field-010"] *{animation:none!important;transition:none!important}}
`

const MONTHS = [
  "января",
  "февраля",
  "марта",
  "апреля",
  "мая",
  "июня",
  "июля",
  "августа",
  "сентября",
  "октября",
  "ноября",
  "декабря",
]

/**
 * Группа полей даты с одной общей ошибкой на fieldset.
 * Один файл, ноль зависимостей, собственная палитра.
 */
export function Field010({
  legend = "Дата рождения",
  error = "31 февраля не существует — проверьте день и месяц.",
  hint = "Нужна, чтобы подтвердить совершеннолетие. Никому не показываем.",
  name = "birth",
  accent,
  className,
  style,
  ...props
}: Field010Props) {
  const noteId = `${name}-note`

  const palette = {
    ...(accent ? { "--vibeui-field-010-accent": accent } : null),
    ...style,
  } as CSSProperties

  return (
    <>
      <style href="vibeui-field-010" precedence="medium">
        {STYLES}
      </style>
      <div
        {...props}
        data-vibeui-block="field-010"
        data-invalid={error ? "true" : undefined}
        className={className}
        style={palette}
      >
        {/* Сообщение связано с группой, а не с одним полем: вслух его слышно
            при входе в любое из трёх. */}
        <fieldset
          aria-describedby={noteId}
          aria-invalid={error ? true : undefined}
        >
          <legend>{legend}</legend>
          <div data-part="row">
            <span data-part="cell" data-size="day">
              <label htmlFor={`${name}-day`}>День</label>
              <input
                id={`${name}-day`}
                name={`${name}-day`}
                type="number"
                inputMode="numeric"
                min={1}
                max={31}
                defaultValue={31}
              />
            </span>
            <span data-part="cell" data-size="month">
              <label htmlFor={`${name}-month`}>Месяц</label>
              <select
                id={`${name}-month`}
                name={`${name}-month`}
                defaultValue="февраля"
              >
                {MONTHS.map((month) => (
                  <option key={month} value={month}>
                    {month}
                  </option>
                ))}
              </select>
            </span>
            <span data-part="cell" data-size="year">
              <label htmlFor={`${name}-year`}>Год</label>
              <input
                id={`${name}-year`}
                name={`${name}-year`}
                type="number"
                inputMode="numeric"
                min={1900}
                max={2026}
                defaultValue={1994}
              />
            </span>
          </div>
          {error ? (
            <p id={noteId} data-part="error" role="alert">
              <span data-part="mark" aria-hidden="true">
                !
              </span>
              {error}
            </p>
          ) : (
            <p id={noteId} data-part="note">
              {hint}
            </p>
          )}
        </fieldset>
      </div>
    </>
  )
}