Label

Required Mark

A label for a required field: an asterisk with a screen-reader-only expansion and one line explaining why the field is there.

  • label
  • form
  • required
  • a11y

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/label-001?lang=en

We send the invoice and your account access there.

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-001" (Required Mark) 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-001.json

Registry item: https://vibeui.ru/r/label-001.json
Installs to: components/vibeui/label-001.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 for a required field: an asterisk with a screen-reader-only expansion and one line explaining why the field is there.

A required-field label with an asterisk, a hidden spoken expansion and an explanation underneath. Zero dependencies, one file, no client JS.

## 3. How to use it
import { Label001 } from "@/components/vibeui/label-001"

<Label001
  label="Work email"
  hint="We send the invoice and your account access there."
  placeholder="name@company.com"
/>

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-001-* palette — do not swap it for your theme tokens
- the visually hidden text next to the asterisk: without it screen readers say "asterisk" instead of "required field"
- aria-hidden on the asterisk itself — otherwise the meaning is announced twice and gets in the way
- the aria-describedby link between the hint and the field: otherwise the line is visible but never spoken
- the native required attribute on the input — browser validation rests on it, with no script
- 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 and the explanation through hint
- the placeholder text through placeholder
- the focus and accent color through accent
- the block width through max-width in the palette

## 7. Rules
- An asterisk only works while required fields are the minority: if almost everything is required, mark the optional ones instead.
- The hint sits ABOVE the field on purpose: on a phone the keyboard covers the bottom of the screen and text under the field is invisible.
- The input type here is email; for another type change autoComplete as well, or autofill will paste the wrong value.
- 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-001.json
https://vibeui.ru/r/label-001.json

Компонент самодостаточен: один файл, без зависимостей, палитра в локальных переменных --vibeui-label-001-*. Серверный: из хуков только useId, состояния нет. Звёздочка помечена aria-hidden, а её смысл несёт визуально скрытый текст «, обязательное поле» — иначе скринридер произносит «звёздочка» и оставляет гадать. Строка-объяснение связана с полем через aria-describedby, поэтому читается сразу после имени поля, а не теряется. Поле получает нативный required: валидация браузера остаётся рабочей. Блок несёт собственную светлую подложку с рамкой — тёмный текст подписи обязан читаться на тёмной карточке каталога.

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 Label001Props = Omit<
  ComponentPropsWithoutRef<"div">,
  "children"
> & {
  label?: string
  hint?: string
  placeholder?: string
  accent?: string
}

// Идея компонента: звёздочка сама по себе ничего не объясняет — половина
// людей читает её как «важное», а не «без этого форму не отправить».
// Поэтому здесь звёздочка нарисована, продублирована текстом для
// скринридера и подкреплена одной строкой, которая говорит зачем поле.
const STYLES = `
:where([data-vibeui-block="label-001"]){
--vibeui-label-001-surface:oklch(1 0 0);
--vibeui-label-001-surface-border:oklch(0.91 0.006 265);
--vibeui-label-001-fg:oklch(0.24 0.016 265);
--vibeui-label-001-muted:oklch(0.54 0.014 265);
--vibeui-label-001-field-border:oklch(0.85 0.01 265);
--vibeui-label-001-accent:oklch(0.55 0.2 262);
--vibeui-label-001-required:oklch(0.58 0.19 25);
--vibeui-label-001-radius:0.625rem;
--vibeui-label-001-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
/* Собственная светлая подложка: подпись — это тёмный текст, и на тёмной
   карточке каталога он обязан читаться без правки палитры проекта. */
[data-vibeui-block="label-001"]{
box-sizing:border-box;width:100%;max-width:24rem;
padding:1rem;border-radius:0.875rem;
background:var(--vibeui-label-001-surface);
border:1px solid var(--vibeui-label-001-surface-border);
font-family:var(--vibeui-label-001-font);color:var(--vibeui-label-001-fg);
display:flex;flex-direction:column;gap:0.375rem;
}
[data-vibeui-block="label-001"] label{
display:inline-flex;align-items:baseline;gap:0.25rem;
font-size:0.875rem;font-weight:600;line-height:1.3;cursor:pointer;
}
/* Звёздочка декоративна: её значение уносит соседний текст для чтения
   вслух, иначе скринридер произносит «звёздочка» и оставляет гадать. */
[data-vibeui-block="label-001"] [data-part="star"]{
color:var(--vibeui-label-001-required);font-size:0.9375rem;line-height:1;
}
[data-vibeui-block="label-001"] [data-part="sr"]{
position:absolute;width:1px;height:1px;padding:0;margin:-1px;
overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0;
}
[data-vibeui-block="label-001"] [data-part="hint"]{
margin:0;font-size:0.8125rem;line-height:1.45;
color:var(--vibeui-label-001-muted);
}
[data-vibeui-block="label-001"] input{
box-sizing:border-box;width:100%;margin-top:0.125rem;
height:2.5rem;padding:0 0.75rem;
font:inherit;font-size:0.9375rem;font-weight:400;
color:var(--vibeui-label-001-fg);background:var(--vibeui-label-001-surface);
border:1px solid var(--vibeui-label-001-field-border);
border-radius:var(--vibeui-label-001-radius);
transition:border-color .16s ease,box-shadow .16s ease;
}
[data-vibeui-block="label-001"] input::placeholder{color:var(--vibeui-label-001-muted)}
[data-vibeui-block="label-001"] input:focus-visible{
outline:none;border-color:var(--vibeui-label-001-accent);
box-shadow:0 0 0 3px color-mix(in oklab,var(--vibeui-label-001-accent) 22%,transparent);
}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="label-001"] *{animation:none!important;transition:none!important}}
`

/**
 * Подпись обязательного поля: звёздочка, скрытая расшифровка для
 * скринридера и строка-объяснение под подписью. Один файл, ноль
 * зависимостей, собственная палитра.
 */
export function Label001({
  label = "Рабочая почта",
  hint = "Пришлём на неё счёт и доступ в кабинет.",
  placeholder = "name@company.com",
  accent,
  className,
  style,
  ...props
}: Label001Props) {
  const id = useId()
  const hintId = `${id}-hint`
  const palette = {
    ...(accent ? { "--vibeui-label-001-accent": accent } : null),
    ...style,
  } as CSSProperties

  return (
    <>
      <style href="vibeui-label-001" precedence="medium">
        {STYLES}
      </style>
      <div
        {...props}
        data-vibeui-block="label-001"
        className={className}
        style={palette}
      >
        <label htmlFor={id}>
          {label}
          <span data-part="star" aria-hidden="true">
            *
          </span>
          <span data-part="sr">, обязательное поле</span>
        </label>
        <p data-part="hint" id={hintId}>
          {hint}
        </p>
        <input
          id={id}
          type="email"
          name="email"
          required
          autoComplete="email"
          placeholder={placeholder}
          aria-describedby={hintId}
        />
      </div>
    </>
  )
}