Label
Side Label
A label to the left of the field for a dense desktop form: the label column is fixed, and at narrow block widths the label moves back on top.
- label
- form
- container-query
- desktop
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-004?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 "label-004" (Side 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-004.json
Registry item: https://vibeui.ru/r/label-004.json
Installs to: components/vibeui/label-004.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 to the left of the field for a dense desktop form: the label column is fixed, and at narrow block widths the label moves back on top.
A form row with the label beside the field: the columns switch on the block's own width and the hint stays aligned under the input. Zero dependencies, one file, no client JS.
## 3. How to use it
import { Label004 } from "@/components/vibeui/label-004"
<Label004
label="Company name"
hint="Exactly as written in your registration details."
labelWidth={9}
/>
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-004-* palette — do not swap it for your theme tokens
- the layout on [data-part="shell"] rather than the root: @container never applies to the container itself
- container-type:inline-size on the root — without it the width query does not fire at all
- the padding-top on the label in two-column mode: without it the label sits above the text inside the field
- the fallback to a single column at narrow widths — a side label eats half the line on a phone
- 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 label column width through labelWidth in rem
- the focus color through accent
- the @container breakpoint and the maximum row width
## 7. Rules
- Size the column by the longest label in the form, or rows will drift apart from each other.
- Right-aligned labels read well only in a narrow column: a wide one opens a gap between label and field.
- The 28rem threshold measures the block, not the window: in a narrow settings panel the label honestly moves on top.
- 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-004.jsonhttps://vibeui.ru/r/label-004.jsonКомпонент самодостаточен: один файл, без зависимостей, палитра в локальных переменных --vibeui-label-004-*. Серверный: из хуков только useId. Корень объявлен container-type:inline-size, но сама раскладка лежит на внутренней оболочке [data-part="shell"] — правило внутри @container не действует на сам контейнер, поэтому переключать grid на корне бессмысленно. Раскладка — grid-template-areas: в один столбец подпись/поле/пояснение идут стопкой, от 28rem собственной ширины подпись становится левой колонкой шириной --vibeui-label-004-label-width, а пояснение остаётся под полем во второй колонке. Подпись получает padding-top, чтобы сидеть на первой строке текста внутри поля, а не на его верхней рамке.
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 Label004Props = Omit<
ComponentPropsWithoutRef<"div">,
"children"
> & {
label?: string
hint?: string
labelWidth?: number
accent?: string
}
// Идея компонента: в плотной десктопной форме подпись сбоку экономит
// вертикаль и даёт полям общий левый край. Раскладка переключается по
// ширине самого блока (container query), а не по ширине окна: в узкой
// колонке настроек подпись возвращается наверх, и это верно даже тогда,
// когда окно широкое.
const STYLES = `
:where([data-vibeui-block="label-004"]){
--vibeui-label-004-surface:oklch(1 0 0);
--vibeui-label-004-surface-border:oklch(0.91 0.006 265);
--vibeui-label-004-fg:oklch(0.24 0.016 265);
--vibeui-label-004-muted:oklch(0.54 0.014 265);
--vibeui-label-004-field-border:oklch(0.85 0.01 265);
--vibeui-label-004-accent:oklch(0.55 0.2 262);
--vibeui-label-004-label-width:9rem;
--vibeui-label-004-radius:0.625rem;
--vibeui-label-004-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
container-type:inline-size;
}
[data-vibeui-block="label-004"]{
box-sizing:border-box;width:100%;max-width:38rem;
padding:1rem;border-radius:0.875rem;
background:var(--vibeui-label-004-surface);
border:1px solid var(--vibeui-label-004-surface-border);
font-family:var(--vibeui-label-004-font);color:var(--vibeui-label-004-fg);
}
/* Раскладка живёт на внутренней оболочке: правило внутри @container не
действует на сам контейнер, поэтому на корне её держать нельзя. */
[data-vibeui-block="label-004"] [data-part="shell"]{
display:grid;grid-template-columns:1fr;gap:0.375rem 1rem;
grid-template-areas:"label" "field" "hint";
}
[data-vibeui-block="label-004"] label{
grid-area:label;
font-size:0.875rem;font-weight:600;line-height:1.35;cursor:pointer;
}
[data-vibeui-block="label-004"] input{
grid-area:field;
box-sizing:border-box;width:100%;height:2.5rem;padding:0 0.75rem;
font:inherit;font-size:0.9375rem;
color:var(--vibeui-label-004-fg);background:var(--vibeui-label-004-surface);
border:1px solid var(--vibeui-label-004-field-border);
border-radius:var(--vibeui-label-004-radius);
transition:border-color .16s ease,box-shadow .16s ease;
}
[data-vibeui-block="label-004"] input:focus-visible{
outline:none;border-color:var(--vibeui-label-004-accent);
box-shadow:0 0 0 3px color-mix(in oklab,var(--vibeui-label-004-accent) 22%,transparent);
}
[data-vibeui-block="label-004"] [data-part="hint"]{
grid-area:hint;margin:0;
font-size:0.8125rem;line-height:1.45;color:var(--vibeui-label-004-muted);
}
@container (min-width: 28rem){
[data-vibeui-block="label-004"] [data-part="shell"]{
grid-template-columns:var(--vibeui-label-004-label-width) minmax(0,1fr);
grid-template-areas:"label field" ". hint";
align-items:start;
}
/* Подпись опускается на строку поля: выравнивание по первой строке
текста внутри поля, а не по его верхнему краю. */
[data-vibeui-block="label-004"] label{padding-top:0.625rem;text-align:right}
}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="label-004"] *{animation:none!important;transition:none!important}}
`
/**
* Подпись слева от поля для десктопной формы: колонка подписи фиксирована,
* на узкой ширине блока подпись уходит наверх. Один файл, ноль зависимостей.
*/
export function Label004({
label = "Название компании",
hint = "Так, как написано в реквизитах, без кавычек и формы собственности.",
labelWidth = 9,
accent,
className,
style,
...props
}: Label004Props) {
const id = useId()
const hintId = `${id}-hint`
const palette = {
"--vibeui-label-004-label-width": `${labelWidth}rem`,
...(accent ? { "--vibeui-label-004-accent": accent } : null),
...style,
} as CSSProperties
return (
<>
<style href="vibeui-label-004" precedence="medium">
{STYLES}
</style>
<div
{...props}
data-vibeui-block="label-004"
className={className}
style={palette}
>
<div data-part="shell">
<label htmlFor={id}>{label}</label>
<input
id={id}
type="text"
name="company"
autoComplete="organization"
aria-describedby={hintId}
/>
<p data-part="hint" id={hintId}>
{hint}
</p>
</div>
</div>
</>
)
}