Native Select

Invalid Select

A native select with a permanent error message instead of the browser's own bubble, which disappears after a couple of seconds.

  • select
  • error
  • validation
  • 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/nativeselect-006?lang=en

Choose a payment method to place the order.

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 "nativeselect-006" (Invalid 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/nativeselect-006.json

Registry item: https://vibeui.ru/r/nativeselect-006.json
Installs to: components/vibeui/nativeselect-006.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 native select with a permanent error message instead of the browser's own bubble, which disappears after a couple of seconds.

A native select in its error state: border, arrow, label and text are painted from a single aria-invalid. Zero dependencies, one file, no client JS.

## 3. How to use it
import { Nativeselect006 } from "@/components/vibeui/nativeselect-006"

<Nativeselect006
  label="Payment method"
  error="Choose a payment method — the order cannot be placed without it."
  options={["Card online", "Cash on 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-nativeselect-006-* palette — do not swap it for your theme tokens
- aria-invalid as the single source of state: a parallel CSS class will drift out of sync sooner or later
- the message kept in the markup — the browser's own bubble vanishes and cannot be re-read
- the aria-describedby link between message and field: otherwise the error is seen but never heard
- the rule beside the error text: it keeps the eye at the field instead of a global problem list
- 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 message through error and the choices through options
- the normal focus color through accent
- the error color through the --vibeui-nativeselect-006-error variable
- the stand-in text inside the empty option

## 7. Rules
- The error is rendered up front: if it appears after submission, add role="alert" to the message or the screen reader stays silent.
- When you drop aria-invalid, drop aria-describedby too, or the field keeps pointing at an empty message.
- The text has to say what to do: "This field is required" does not help, "Choose a payment method" does.
- 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/nativeselect-006.json
https://vibeui.ru/r/nativeselect-006.json

Компонент самодостаточен: один файл, без зависимостей, палитра в локальных переменных --vibeui-nativeselect-006-*. Серверный: из хуков только useId. Единственный источник состояния — aria-invalid на поле: от него красятся рамка, стрелка (через :has() на корне), подпись и обводка фокуса, отдельного класса «error» нет и состояния не расходятся. Сообщение остаётся в разметке постоянно и связано с полем через aria-describedby — в отличие от штатной подсказки браузера, которая показывается один раз и пропадает. Цвет незаполненного поля даёт правило select:not(:invalid), а заглушка сделана option с пустым value.

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 Nativeselect006Props = Omit<
  ComponentPropsWithoutRef<"select">,
  "children" | "size" | "defaultValue"
> & {
  label?: string
  error?: string
  options?: string[]
  accent?: string
}

// Идея компонента: у select ошибка почти всегда одна — «не выбрано», и
// всплывающая подсказка браузера её показывает ровно один раз, а потом
// исчезает. Здесь сообщение живёт в разметке постоянно: полоса слева
// у текста ошибки держит взгляд у поля, стрелка и рамка перекрашиваются
// от того же aria-invalid, что и сообщение.
const STYLES = `
:where([data-vibeui-block="nativeselect-006"]){
--vibeui-nativeselect-006-surface:oklch(1 0 0);
--vibeui-nativeselect-006-surface-border:oklch(0.91 0.006 265);
--vibeui-nativeselect-006-fg:oklch(0.24 0.016 265);
--vibeui-nativeselect-006-muted:oklch(0.58 0.014 265);
--vibeui-nativeselect-006-field-border:oklch(0.85 0.01 265);
--vibeui-nativeselect-006-accent:oklch(0.55 0.2 262);
--vibeui-nativeselect-006-error:oklch(0.55 0.2 25);
--vibeui-nativeselect-006-radius:0.625rem;
--vibeui-nativeselect-006-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="nativeselect-006"]{
box-sizing:border-box;width:100%;max-width:22rem;
padding:1rem;border-radius:0.875rem;
background:var(--vibeui-nativeselect-006-surface);
border:1px solid var(--vibeui-nativeselect-006-surface-border);
font-family:var(--vibeui-nativeselect-006-font);color:var(--vibeui-nativeselect-006-fg);
display:flex;flex-direction:column;gap:0.375rem;
}
[data-vibeui-block="nativeselect-006"] label{
font-size:0.875rem;font-weight:600;line-height:1.3;cursor:pointer;
}
[data-vibeui-block="nativeselect-006"] [data-part="field"]{position:relative;display:flex}
[data-vibeui-block="nativeselect-006"] select{
appearance:none;-webkit-appearance:none;
box-sizing:border-box;width:100%;height:2.5rem;
padding:0 2.25rem 0 0.75rem;
font:inherit;font-size:0.9375rem;line-height:1.2;
color:var(--vibeui-nativeselect-006-muted);
background:var(--vibeui-nativeselect-006-surface);
border:1px solid var(--vibeui-nativeselect-006-field-border);
border-radius:var(--vibeui-nativeselect-006-radius);
cursor:pointer;
transition:border-color .16s ease,box-shadow .16s ease;
}
[data-vibeui-block="nativeselect-006"] select:not(:invalid){color:var(--vibeui-nativeselect-006-fg)}
[data-vibeui-block="nativeselect-006"] select[aria-invalid="true"]{
border-color:var(--vibeui-nativeselect-006-error);
}
[data-vibeui-block="nativeselect-006"] select:focus-visible{
outline:none;border-color:var(--vibeui-nativeselect-006-accent);
box-shadow:0 0 0 3px color-mix(in oklab,var(--vibeui-nativeselect-006-accent) 22%,transparent);
}
[data-vibeui-block="nativeselect-006"] select[aria-invalid="true"]:focus-visible{
border-color:var(--vibeui-nativeselect-006-error);
box-shadow:0 0 0 3px color-mix(in oklab,var(--vibeui-nativeselect-006-error) 22%,transparent);
}
[data-vibeui-block="nativeselect-006"] option{color:var(--vibeui-nativeselect-006-fg)}
[data-vibeui-block="nativeselect-006"] [data-part="arrow"]{
position:absolute;right:0.875rem;top:50%;pointer-events:none;
width:0.4375rem;height:0.4375rem;
border-right:1.5px solid var(--vibeui-nativeselect-006-muted);
border-bottom:1.5px solid var(--vibeui-nativeselect-006-muted);
translate:0 -0.1875rem;rotate:45deg;
}
/* Одна точка правды — aria-invalid на поле: подпись, стрелка и сообщение
   красятся от него, поэтому состояния не расходятся. */
[data-vibeui-block="nativeselect-006"]:has(select[aria-invalid="true"]) label{
color:var(--vibeui-nativeselect-006-error);
}
[data-vibeui-block="nativeselect-006"]:has(select[aria-invalid="true"]) [data-part="arrow"]{
border-color:var(--vibeui-nativeselect-006-error);
}
[data-vibeui-block="nativeselect-006"] [data-part="error"]{
margin:0;padding-left:0.5rem;
border-left:2px solid var(--vibeui-nativeselect-006-error);
font-size:0.8125rem;line-height:1.4;color:var(--vibeui-nativeselect-006-error);
}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="nativeselect-006"] *{animation:none!important;transition:none!important}}
`

/**
 * Нативный select с постоянным сообщением об ошибке вместо всплывающей
 * подсказки браузера. Один файл, ноль зависимостей.
 */
export function Nativeselect006({
  label = "Способ оплаты",
  error = "Выберите способ оплаты — без него заказ не оформить.",
  options = ["Картой онлайн", "Наличными курьеру", "Счёт для юрлица"],
  accent,
  className,
  style,
  ...props
}: Nativeselect006Props) {
  const id = useId()
  const errorId = `${id}-error`
  const palette = {
    ...(accent ? { "--vibeui-nativeselect-006-accent": accent } : null),
    ...style,
  } as CSSProperties

  return (
    <>
      <style href="vibeui-nativeselect-006" precedence="medium">
        {STYLES}
      </style>
      <div
        data-vibeui-block="nativeselect-006"
        className={className}
        style={palette}
      >
        <label htmlFor={id}>{label}</label>
        <div data-part="field">
          <select
            {...props}
            id={id}
            name="payment"
            required
            defaultValue=""
            aria-invalid="true"
            aria-describedby={errorId}
          >
            <option value="" disabled hidden>
              Не выбрано
            </option>
            {options.map((option) => (
              <option key={option} value={option}>
                {option}
              </option>
            ))}
          </select>
          <span data-part="arrow" aria-hidden="true" />
        </div>
        <p data-part="error" id={errorId}>
          {error}
        </p>
      </div>
    </>
  )
}