Inputs

Described Select

A select with an explanation living underneath it: a short name in the field, the consequences of the choice on a separate line.

  • select
  • description
  • form
  • 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/select-005?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 "select-005" (Described Select) 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/select-005.json

Registry item: https://vibeui.ru/r/select-005.json
Installs to: components/vibeui/select-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 select with an explanation living underneath it: a short name in the field, the consequences of the choice on a separate line.

A select that shows an explanation of the chosen option in a live line under the field. One file, zero dependencies, a client component.

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

<Select005
  label="Project role"
  defaultValue="admin"
/>

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-select-005-* palette — do not swap it for your theme tokens
- the aria-describedby link to the explanation paragraph: otherwise a screen reader never gets it
- role="status" on the explanation: the text change is announced without stealing focus from the field
- the explanation as a separate node rather than inside option — the system list cannot draw a second line
- the component's own light surface — without it the dark text disappears on a dark page
- the visible focus ring on the select: the border and shadow are the only sign the field is active

## 6. You may change
- the field caption through label
- the options together with their descriptions through options
- the initial value through defaultValue
- the accent colour through accent

## 7. Rules
- Keep the description to one or two lines: the height jump on switching is more noticeable than it looks in a mockup.
- Past a dozen options an explanation stops helping — you need search, not prose.
- role="status" announces politely: critical warnings need role="alert" instead.
- 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/select-005.json
https://vibeui.ru/r/select-005.json

Клиентский компонент: useState держит значение, чтобы подставлять описание текущего варианта. Пояснение связано с полем через aria-describedby и объявлено role="status", поэтому смена текста читается вслух без перевода фокуса. Внутрь <option> описание положить нельзя — системный список рисует только текст, отсюда отдельный абзац. Палитра в --vibeui-select-005-*, зависимостей нет.

Component source

The same file your agent installs. Here in case you would rather copy it by hand.

"use client"

import { useId, useState } from "react"
import type { ComponentPropsWithoutRef, CSSProperties } from "react"

export type Select005Option = {
  value: string
  label: string
  description: string
}

export type Select005Props = Omit<
  ComponentPropsWithoutRef<"div">,
  "children" | "onChange"
> & {
  label?: string
  options?: Select005Option[]
  defaultValue?: string
  accent?: string
}

// Идея компонента: короткое название в поле, объяснение — под ним. Роли,
// планы и режимы почти всегда требуют одной поясняющей строки, но внутрь
// <option> её не поместить: системный список рисует только текст. Поэтому
// пояснение живёт отдельным абзацем и переключается вместе со значением.
const STYLES = `
:where([data-vibeui-block="select-005"]){
--vibeui-select-005-surface:oklch(1 0 0);
--vibeui-select-005-surface-border:oklch(0.91 0.006 265);
--vibeui-select-005-fg:oklch(0.23 0.016 265);
--vibeui-select-005-muted:oklch(0.52 0.014 265);
--vibeui-select-005-field:oklch(0.985 0.002 265);
--vibeui-select-005-border:oklch(0.87 0.008 265);
--vibeui-select-005-accent:oklch(0.55 0.19 262);
--vibeui-select-005-note:oklch(0.55 0.19 262 / 8%);
--vibeui-select-005-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="select-005"]{
display:flex;flex-direction:column;gap:0.5rem;
width:100%;max-width:21rem;box-sizing:border-box;padding:0.875rem;
background:var(--vibeui-select-005-surface);
border:1px solid var(--vibeui-select-005-surface-border);border-radius:0.875rem;
font-family:var(--vibeui-select-005-font);color:var(--vibeui-select-005-fg);
}
[data-vibeui-block="select-005"] [data-part="label"]{font-size:0.8125rem;font-weight:600}
[data-vibeui-block="select-005"] [data-part="field"]{position:relative;display:block}
[data-vibeui-block="select-005"] select{
appearance:none;-webkit-appearance:none;
width:100%;box-sizing:border-box;margin:0;height:2.75rem;
padding:0 2.5rem 0 0.875rem;
border:1px solid var(--vibeui-select-005-border);border-radius:0.625rem;
background:var(--vibeui-select-005-field);color:inherit;
font:inherit;font-size:0.9375rem;cursor:pointer;
transition:border-color .16s ease,box-shadow .16s ease;
}
[data-vibeui-block="select-005"] select:focus{
outline:none;border-color:var(--vibeui-select-005-accent);
box-shadow:0 0 0 3px color-mix(in oklab,var(--vibeui-select-005-accent) 22%,transparent);
}
[data-vibeui-block="select-005"] [data-part="arrow"]{
position:absolute;right:1rem;top:50%;
width:0.4375rem;height:0.4375rem;margin-top:-0.3125rem;pointer-events:none;
border-right:1.5px solid var(--vibeui-select-005-muted);
border-bottom:1.5px solid var(--vibeui-select-005-muted);
transform:rotate(45deg);
}
/* Пояснение — часть поля, а не подсказка: оно объявлено через
   aria-describedby и обновляется как живая область. */
[data-vibeui-block="select-005"] [data-part="note"]{
display:flex;gap:0.5rem;margin:0;padding:0.5rem 0.625rem;
border-radius:0.5rem;background:var(--vibeui-select-005-note);
font-size:0.75rem;line-height:1.45;color:var(--vibeui-select-005-muted);
}
[data-vibeui-block="select-005"] [data-part="mark"]{
flex:none;color:var(--vibeui-select-005-accent);font-weight:700;
}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="select-005"] *{animation:none!important;transition:none!important}}
`

const DEFAULT_OPTIONS: Select005Option[] = [
  {
    value: "viewer",
    label: "Наблюдатель",
    description: "Видит проект и комментарии, но ничего не меняет.",
  },
  {
    value: "editor",
    label: "Редактор",
    description: "Правит содержимое и публикует, но не зовёт новых людей.",
  },
  {
    value: "admin",
    label: "Администратор",
    description: "Управляет доступами, оплатой и может удалить проект.",
  },
]

/**
 * Select с пояснением: под полем живая строка про выбранный вариант.
 * Один файл, ноль зависимостей, собственная палитра.
 */
export function Select005({
  label = "Роль в проекте",
  options = DEFAULT_OPTIONS,
  defaultValue = "editor",
  accent,
  className,
  style,
  ...props
}: Select005Props) {
  const id = useId()
  const [value, setValue] = useState(defaultValue)
  const current = options.find((option) => option.value === value) ?? options[0]

  const palette = {
    ...(accent ? { "--vibeui-select-005-accent": accent } : null),
    ...style,
  } as CSSProperties

  return (
    <>
      <style href="vibeui-select-005" precedence="medium">
        {STYLES}
      </style>
      <div
        {...props}
        data-vibeui-block="select-005"
        className={className}
        style={palette}
      >
        <label data-part="label" htmlFor={id}>
          {label}
        </label>
        <span data-part="field">
          <select
            id={id}
            value={value}
            aria-describedby={`${id}-note`}
            onChange={(event) => setValue(event.target.value)}
          >
            {options.map((option) => (
              <option key={option.value} value={option.value}>
                {option.label}
              </option>
            ))}
          </select>
          <span data-part="arrow" aria-hidden="true" />
        </span>
        <p data-part="note" id={`${id}-note`} role="status">
          <span data-part="mark" aria-hidden="true">
            →
          </span>
          {current?.description}
        </p>
      </div>
    </>
  )
}