Label
Error Label
A label with the error message between it and the field: the entire error styling hangs on a single aria-invalid attribute.
- label
- error
- validation
- a11y
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/label-007?lang=en
No such address: check that a domain follows the @.
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 "label-007" (Error Label) 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/label-007.json
Registry item: https://vibeui.ru/r/label-007.json
Installs to: components/vibeui/label-007.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 label with the error message between it and the field: the entire error styling hangs on a single aria-invalid attribute.
A label with an error message: the state is driven by one aria-invalid, and the text is tied to the field and backed by an icon. Zero dependencies, one file, no client JS.
## 3. How to use it
import { Label007 } from "@/components/vibeui/label-007"
<Label007
label="Billing email"
error="No such address: check the domain after the @."
defaultValue="accounting@company"
/>
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-label-007-* palette — do not swap it for your theme tokens
- aria-invalid as the single source of state: a parallel CSS class will drift out of sync sooner or later
- the aria-describedby link between message and field — otherwise the error is seen but never heard
- the icon next to the text: color alone fails color-blind readers and greyscale printing
- the message above the field — on a phone the keyboard covers everything below the input
- 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 and the typed value through defaultValue
- the normal focus color through accent
- the error colors through the --vibeui-label-007-error and --vibeui-label-007-error-soft variables
- the input type and autofill hint for your own case
## 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.
- The message has to say what to fix rather than "invalid value", or people get stuck.
- When you drop aria-invalid, drop aria-describedby too, or the field keeps pointing at 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/label-007.jsonhttps://vibeui.ru/r/label-007.jsonКомпонент самодостаточен: один файл, без зависимостей, палитра в локальных переменных --vibeui-label-007-*. Серверный: из хуков только useId. Единственный источник состояния — aria-invalid у поля: подпись краснеет правилом :has(input[aria-invalid="true"]), рамка и обводка фокуса — селектором по тому же атрибуту. Отдельного класса «error» нет, поэтому состояния не разъезжаются. Сообщение стоит между подписью и полем: на телефоне клавиатура закрывает низ экрана, и текст под полем не виден. К цвету добавлен нарисованный рамкой значок — цвет не должен быть единственным признаком ошибки. Сообщение связано с полем через aria-describedby.
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 Label007Props = Omit<
ComponentPropsWithoutRef<"div">,
"children" | "defaultValue"
> & {
label?: string
error?: string
defaultValue?: string
accent?: string
}
// Идея компонента: сообщение об ошибке стоит между подписью и полем — так
// его видно до того, как палец на телефоне закроет низ поля клавиатурой.
// Вся раскраска висит на одном атрибуте aria-invalid у поля: включил
// атрибут — покраснела рамка, подпись и текст, отдельного класса нет.
const STYLES = `
:where([data-vibeui-block="label-007"]){
--vibeui-label-007-surface:oklch(1 0 0);
--vibeui-label-007-surface-border:oklch(0.91 0.006 265);
--vibeui-label-007-fg:oklch(0.24 0.016 265);
--vibeui-label-007-muted:oklch(0.54 0.014 265);
--vibeui-label-007-field-border:oklch(0.85 0.01 265);
--vibeui-label-007-accent:oklch(0.55 0.2 262);
--vibeui-label-007-error:oklch(0.55 0.2 25);
--vibeui-label-007-error-soft:oklch(0.96 0.03 25);
--vibeui-label-007-radius:0.625rem;
--vibeui-label-007-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="label-007"]{
box-sizing:border-box;width:100%;max-width:24rem;
padding:1rem;border-radius:0.875rem;
background:var(--vibeui-label-007-surface);
border:1px solid var(--vibeui-label-007-surface-border);
font-family:var(--vibeui-label-007-font);color:var(--vibeui-label-007-fg);
display:flex;flex-direction:column;gap:0.375rem;
}
[data-vibeui-block="label-007"] label{
font-size:0.875rem;font-weight:600;line-height:1.3;cursor:pointer;
transition:color .16s ease;
}
/* Одна точка правды — aria-invalid на поле. :has() красит подпись и
сообщение от того же атрибута, поэтому состояния не разъезжаются. */
[data-vibeui-block="label-007"]:has(input[aria-invalid="true"]) label{
color:var(--vibeui-label-007-error);
}
[data-vibeui-block="label-007"] [data-part="error"]{
display:flex;align-items:flex-start;gap:0.375rem;margin:0;
padding:0.375rem 0.5rem;border-radius:0.5rem;
background:var(--vibeui-label-007-error-soft);
font-size:0.8125rem;line-height:1.4;color:var(--vibeui-label-007-error);
}
/* Значок нарисован рамкой, а не картинкой: цвет ошибки — единственный
признак состояния только для зрячих, значок добавляет второй. */
[data-vibeui-block="label-007"] [data-part="sign"]{
flex:none;margin-top:0.0625rem;
width:0.875rem;height:0.875rem;border-radius:50%;
border:1px solid currentColor;
display:inline-flex;align-items:center;justify-content:center;
font-size:0.625rem;font-weight:700;line-height:1;
}
[data-vibeui-block="label-007"] input{
box-sizing:border-box;width:100%;height:2.5rem;padding:0 0.75rem;
font:inherit;font-size:0.9375rem;
color:var(--vibeui-label-007-fg);background:var(--vibeui-label-007-surface);
border:1px solid var(--vibeui-label-007-field-border);
border-radius:var(--vibeui-label-007-radius);
transition:border-color .16s ease,box-shadow .16s ease;
}
[data-vibeui-block="label-007"] input[aria-invalid="true"]{
border-color:var(--vibeui-label-007-error);
}
[data-vibeui-block="label-007"] input:focus-visible{
outline:none;border-color:var(--vibeui-label-007-accent);
box-shadow:0 0 0 3px color-mix(in oklab,var(--vibeui-label-007-accent) 22%,transparent);
}
[data-vibeui-block="label-007"] input[aria-invalid="true"]:focus-visible{
border-color:var(--vibeui-label-007-error);
box-shadow:0 0 0 3px color-mix(in oklab,var(--vibeui-label-007-error) 22%,transparent);
}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="label-007"] *{animation:none!important;transition:none!important}}
`
/**
* Подпись с сообщением об ошибке под ней: состояние задаётся одним
* aria-invalid, текст связан с полем через aria-describedby. Один файл,
* ноль зависимостей.
*/
export function Label007({
label = "Почта для счетов",
error = "Такой почты не существует: проверьте, что после @ стоит домен.",
defaultValue = "buhgalter@company",
accent,
className,
style,
...props
}: Label007Props) {
const id = useId()
const errorId = `${id}-error`
const palette = {
...(accent ? { "--vibeui-label-007-accent": accent } : null),
...style,
} as CSSProperties
return (
<>
<style href="vibeui-label-007" precedence="medium">
{STYLES}
</style>
<div
{...props}
data-vibeui-block="label-007"
className={className}
style={palette}
>
<label htmlFor={id}>{label}</label>
<p data-part="error" id={errorId}>
<span data-part="sign" aria-hidden="true">
!
</span>
{error}
</p>
<input
id={id}
type="email"
name="billing-email"
defaultValue={defaultValue}
aria-invalid="true"
aria-describedby={errorId}
/>
</div>
</>
)
}