Label
Optional Tag
A label with an "optional" tag on the right edge of the line: the minority of fields is marked, instead of asterisking the majority.
- label
- optional
- form
- layout
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-003?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-003" (Optional Tag) 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-003.json
Registry item: https://vibeui.ru/r/label-003.json
Installs to: components/vibeui/label-003.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 an "optional" tag on the right edge of the line: the minority of fields is marked, instead of asterisking the majority.
A label with a textual "optional" tag on the right edge of the line and a textarea underneath. Zero dependencies, one file, no client JS.
## 3. How to use it
import { Label003 } from "@/components/vibeui/label-003"
<Label003
label="Note for the courier"
optionalText="optional"
placeholder="For example: call an hour before delivery"
/>
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-003-* palette — do not swap it for your theme tokens
- align-items:baseline on the label row: the smaller tag otherwise floats upward
- the tag as a word rather than an icon or a color alone — the state must survive being read aloud and printed in grey
- the muted contrast of the tag: equal weight with the label turns the form into mush
- resize:vertical on the field — horizontal resizing breaks the form width
- 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 tag wording through optionalText and the stub text through placeholder
- the focus color through accent
- the pill background through the --vibeui-label-003-tag-bg variable
- the field height through rows and min-height
## 7. Rules
- Never mix asterisks and "optional" tags in one form: people stop knowing what the default is.
- The tag does not drive validation — drop required from the field separately, or the form lies.
- At very narrow widths the label and the tag close in on each other: keep the label short or let the row wrap.
- 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-003.jsonhttps://vibeui.ru/r/label-003.jsonКомпонент самодостаточен: один файл, без зависимостей, палитра в локальных переменных --vibeui-label-003-*. Серверный: из хуков только useId. Строка подписи — flex с justify-content:space-between и align-items:baseline: пометка прижата к правому краю, но сидит на одной базовой линии с подписью, хотя кегль у неё меньше. Пометка сделана обычным текстом в пилюле, а не иконкой и не цветом: признак «необязательно» обязан читаться и вслух, и в чёрно-белой печати. Поле — textarea с resize:vertical, чтобы длинный комментарий можно было раскрыть, не ломая ширину формы.
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 Label003Props = Omit<
ComponentPropsWithoutRef<"div">,
"children"
> & {
label?: string
optionalText?: string
placeholder?: string
accent?: string
}
// Идея компонента: если обязательных полей в форме большинство, звёздочки
// превращаются в шум — дешевле пометить меньшинство. Пометка стоит на
// правом краю строки подписи: глаз проходит форму по левому краю и по
// правому отдельно, поэтому «необязательно» видно, не мешая читать имена.
const STYLES = `
:where([data-vibeui-block="label-003"]){
--vibeui-label-003-surface:oklch(1 0 0);
--vibeui-label-003-surface-border:oklch(0.91 0.006 265);
--vibeui-label-003-fg:oklch(0.24 0.016 265);
--vibeui-label-003-muted:oklch(0.54 0.014 265);
--vibeui-label-003-tag-bg:oklch(0.96 0.004 265);
--vibeui-label-003-field-border:oklch(0.85 0.01 265);
--vibeui-label-003-accent:oklch(0.55 0.2 262);
--vibeui-label-003-radius:0.625rem;
--vibeui-label-003-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="label-003"]{
box-sizing:border-box;width:100%;max-width:26rem;
padding:1rem;border-radius:0.875rem;
background:var(--vibeui-label-003-surface);
border:1px solid var(--vibeui-label-003-surface-border);
font-family:var(--vibeui-label-003-font);color:var(--vibeui-label-003-fg);
display:flex;flex-direction:column;gap:0.4375rem;
}
/* Подпись и пометка разведены по краям строки: baseline держит их на
одной линии, даже когда у пометки другой кегль. */
[data-vibeui-block="label-003"] [data-part="row"]{
display:flex;align-items:baseline;justify-content:space-between;
gap:0.75rem;
}
[data-vibeui-block="label-003"] label{
font-size:0.875rem;font-weight:600;line-height:1.3;cursor:pointer;
}
[data-vibeui-block="label-003"] [data-part="tag"]{
flex:none;padding:0.0625rem 0.4375rem;border-radius:999px;
font-size:0.6875rem;font-weight:500;line-height:1.5;letter-spacing:0.01em;
color:var(--vibeui-label-003-muted);background:var(--vibeui-label-003-tag-bg);
}
[data-vibeui-block="label-003"] textarea{
box-sizing:border-box;width:100%;min-height:5rem;resize:vertical;
padding:0.5rem 0.75rem;
font:inherit;font-size:0.9375rem;line-height:1.45;
color:var(--vibeui-label-003-fg);background:var(--vibeui-label-003-surface);
border:1px solid var(--vibeui-label-003-field-border);
border-radius:var(--vibeui-label-003-radius);
transition:border-color .16s ease,box-shadow .16s ease;
}
[data-vibeui-block="label-003"] textarea::placeholder{color:var(--vibeui-label-003-muted)}
[data-vibeui-block="label-003"] textarea:focus-visible{
outline:none;border-color:var(--vibeui-label-003-accent);
box-shadow:0 0 0 3px color-mix(in oklab,var(--vibeui-label-003-accent) 22%,transparent);
}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="label-003"] *{animation:none!important;transition:none!important}}
`
/**
* Подпись с пометкой «необязательно» на правом краю строки: помечено
* меньшинство, а не большинство. Один файл, ноль зависимостей.
*/
export function Label003({
label = "Комментарий к заказу",
optionalText = "необязательно",
placeholder = "Например: позвонить за час до доставки",
accent,
className,
style,
...props
}: Label003Props) {
const id = useId()
const palette = {
...(accent ? { "--vibeui-label-003-accent": accent } : null),
...style,
} as CSSProperties
return (
<>
<style href="vibeui-label-003" precedence="medium">
{STYLES}
</style>
<div
{...props}
data-vibeui-block="label-003"
className={className}
style={palette}
>
<div data-part="row">
<label htmlFor={id}>{label}</label>
<span data-part="tag">{optionalText}</span>
</div>
<textarea id={id} name="comment" rows={3} placeholder={placeholder} />
</div>
</>
)
}