Label

Group Legend

A group label on a <legend> inside a <fieldset>: the question covers every radio at once and is repeated before each of them.

  • label
  • fieldset
  • legend
  • radio

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-005?lang=en

How should we deliver

You can change this until the courier leaves.

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-005" (Group Legend) 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-005.json

Registry item: https://vibeui.ru/r/label-005.json
Installs to: components/vibeui/label-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 group label on a <legend> inside a <fieldset>: the question covers every radio at once and is repeated before each of them.

A radio group with a shared question in a <legend>: the chosen row is highlighted and focus lands on the whole row. Zero dependencies, one file, no client JS.

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

<Label005
  legend="How should we deliver"
  hint="You can change this until the courier leaves."
  options={["Courier to the door", "Pickup point", "Postal service"]}
/>

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-005-* palette — do not swap it for your theme tokens
- the fieldset + legend pair: replacing it with a <div> and a <p> loses the question repeated before every option
- clear:both on the hint and the shell: a floated legend makes the following children wrap around it
- the shared name on the radios — without it they stop being one group and all get selected
- the focus ring on the row through :has(): a highlighted circle misstates the real tap target
- the block's own light surface: without it the dark text disappears on a dark background

## 6. You may change
- the group question through legend, the explanation through hint and the choices through options
- the selected-state color through accent
- the row rounding through the --vibeui-label-005-radius variable
- the number of options: the layout is vertical and takes any count

## 7. Rules
- The first option is pre-selected: if the choice has to be deliberate, drop defaultChecked and add required.
- More than five or six options belong in a select — a vertical list stops fitting the screen.
- The hint is tied to the fieldset through aria-describedby: moving it inside an option row breaks that link.
- 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-005.json
https://vibeui.ru/r/label-005.json

Компонент самодостаточен: один файл, без зависимостей, палитра в локальных переменных --vibeui-label-005-*. Серверный: из хуков только useId, состояние держат нативные радиокнопки одного name. Заголовок группы — <legend>, а не <label>: <label> подписывает одно поле, а вопрос относится ко всем вариантам, и озвучка повторяет legend перед каждым. У legend снята его особая раскладка внутри рамки приёмом float:left;width:100%; плата за это — обтекание, поэтому пояснение и оболочка вариантов получают clear:both. Отметка варианта подсвечивает всю строку через :has(input:checked), обводка фокуса ставится на строку через :has(input:focus-visible) — цель нажатия видна целиком.

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 Label005Props = Omit<
  ComponentPropsWithoutRef<"fieldset">,
  "children"
> & {
  legend?: string
  hint?: string
  options?: string[]
  accent?: string
}

// Идея компонента: у группы переключателей своя подпись, и это не <label>.
// Обычный <label> подписывает одно поле; вопрос «как доставить» относится
// ко всем сразу, поэтому он живёт в <legend> внутри <fieldset> — скринридер
// повторяет его перед каждым вариантом, и человек не теряет вопрос.
const STYLES = `
:where([data-vibeui-block="label-005"]){
--vibeui-label-005-surface:oklch(1 0 0);
--vibeui-label-005-surface-border:oklch(0.91 0.006 265);
--vibeui-label-005-fg:oklch(0.24 0.016 265);
--vibeui-label-005-muted:oklch(0.54 0.014 265);
--vibeui-label-005-item-border:oklch(0.88 0.008 265);
--vibeui-label-005-accent:oklch(0.55 0.2 262);
--vibeui-label-005-radius:0.625rem;
--vibeui-label-005-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="label-005"]{
box-sizing:border-box;width:100%;max-width:24rem;
margin:0;padding:1rem;
background:var(--vibeui-label-005-surface);
border:1px solid var(--vibeui-label-005-surface-border);border-radius:0.875rem;
font-family:var(--vibeui-label-005-font);color:var(--vibeui-label-005-fg);
}
/* float:left + width:100% снимает с <legend> его особую раскладку внутри
   рамки. Плата за это — следующие дети начинают обтекать заголовок,
   поэтому оболочка ниже принудительно сбрасывает обтекание. */
[data-vibeui-block="label-005"] legend{
float:left;width:100%;padding:0;margin:0;
font-size:0.875rem;font-weight:600;line-height:1.3;
}
[data-vibeui-block="label-005"] [data-part="hint"]{
clear:both;margin:0.25rem 0 0;
font-size:0.8125rem;line-height:1.45;color:var(--vibeui-label-005-muted);
}
[data-vibeui-block="label-005"] [data-part="shell"]{
clear:both;display:flex;flex-direction:column;gap:0.5rem;margin-top:0.75rem;
}
[data-vibeui-block="label-005"] [data-part="item"]{
display:flex;align-items:center;gap:0.625rem;cursor:pointer;
padding:0.5625rem 0.75rem;
border:1px solid var(--vibeui-label-005-item-border);
border-radius:var(--vibeui-label-005-radius);
font-size:0.9375rem;line-height:1.35;
transition:border-color .16s ease,background-color .16s ease;
}
[data-vibeui-block="label-005"] [data-part="item"]:has(input:checked){
border-color:var(--vibeui-label-005-accent);
background:color-mix(in oklab,var(--vibeui-label-005-accent) 8%,transparent);
}
[data-vibeui-block="label-005"] [data-part="item"]:has(input:focus-visible){
outline:2px solid var(--vibeui-label-005-accent);outline-offset:2px;
}
[data-vibeui-block="label-005"] input{
appearance:none;-webkit-appearance:none;flex:none;margin:0;
width:1.0625rem;height:1.0625rem;border-radius:50%;
border:1.5px solid var(--vibeui-label-005-item-border);
background:var(--vibeui-label-005-surface);cursor:inherit;
transition:border-color .16s ease,box-shadow .16s ease;
}
[data-vibeui-block="label-005"] input:checked{
border-color:var(--vibeui-label-005-accent);
box-shadow:inset 0 0 0 0.25rem var(--vibeui-label-005-accent);
}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="label-005"] *{animation:none!important;transition:none!important}}
`

/**
 * Подпись группы полей на <legend>: вопрос относится ко всем вариантам
 * сразу и читается перед каждым. Один файл, ноль зависимостей.
 */
export function Label005({
  legend = "Как доставить заказ",
  hint = "Способ можно поменять до того, как курьер выехал.",
  options = ["Курьером до двери", "В пункт выдачи", "Почтой России"],
  accent,
  className,
  style,
  ...props
}: Label005Props) {
  const id = useId()
  const hintId = `${id}-hint`
  const palette = {
    ...(accent ? { "--vibeui-label-005-accent": accent } : null),
    ...style,
  } as CSSProperties

  return (
    <>
      <style href="vibeui-label-005" precedence="medium">
        {STYLES}
      </style>
      <fieldset
        {...props}
        data-vibeui-block="label-005"
        className={className}
        style={palette}
        aria-describedby={hintId}
      >
        <legend>{legend}</legend>
        <p data-part="hint" id={hintId}>
          {hint}
        </p>
        <div data-part="shell">
          {options.map((option, index) => (
            <label data-part="item" key={option}>
              <input
                type="radio"
                name={`${id}-delivery`}
                value={option}
                defaultChecked={index === 0}
              />
              {option}
            </label>
          ))}
        </div>
      </fieldset>
    </>
  )
}