Autocomplete
Catalog Lookup
Each suggestion is a row-card: title, SKU, price and stock — a name alone does not identify a product.
- autocomplete
- search
- catalog
- commerce
Preview
1440pxHost theme
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/autocomplete-006?lang=en
- Кабель USB-C / USB-C, 1 м790 ₽Артикул 41-20834 шт
- Кабель USB-C / Lightning, 2 м1 290 ₽Артикул 41-3116 шт
- Кабель HDMI 2.1, 3 м2 450 ₽Артикул 52-104нет в наличии
- Кабель Ethernet Cat 6, 5 м990 ₽Артикул 63-770118 шт
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 "autocomplete-006" (Catalog Lookup) 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/autocomplete-006.json
Registry item: https://vibeui.ru/r/autocomplete-006.json
Installs to: components/vibeui/autocomplete-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
Each suggestion is a row-card: title, SKU, price and stock — a name alone does not identify a product.
Inventory lookup: every suggestion carries title, SKU, price and stock, and the query matches both name and SKU. Zero dependencies, one file, its own palette.
## 3. How to use it
import { Autocomplete006 } from "@/components/vibeui/autocomplete-006"
<Autocomplete006
items={[{ title: "HDMI cable", meta: "SKU 52-104", price: "$29", stock: 0 }]}
onSelect={(title) => console.log(title)}
/>
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-autocomplete-006-* palette — do not swap it for your theme tokens
- the four fields per row: forty similar products cannot be told apart by name
- SKU matching alongside the name — warehouses search by number
- the colour on zero stock: it cannot be sold, and that must be visible before the click
- tabular figures for price and stock — the columns jump otherwise
- the grid row layout instead of nested flexboxes
## 6. You may change
- the items array and the field names for your catalogue
- the label and placeholder
- the onSelect handler
- the accent through the accent prop
## 7. Rules
- Price is a string: format it on your side, the component computes nothing.
- Zero stock reads as "out of stock" rather than blank: an empty cell reads as missing data.
- For large catalogues replace the local filter with a server query — see autocomplete-005.
- 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/autocomplete-006.jsonhttps://vibeui.ru/r/autocomplete-006.jsonКомпонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-autocomplete-006-*. Клиентский: "use client". Строка списка — grid в две колонки и две строки: слева название и артикул, справа цена и остаток. Нулевой остаток красится отдельной переменной --vibeui-autocomplete-006-warn. Поиск идёт и по названию, и по артикулу.
Component source
The same file your agent installs. Here in case you would rather copy it by hand.
"use client"
import { useId, useMemo, useState } from "react"
import type { ComponentPropsWithoutRef, CSSProperties } from "react"
export type Autocomplete006Item = {
title: string
meta: string
price: string
stock?: number
}
export type Autocomplete006Props = Omit<
ComponentPropsWithoutRef<"div">,
"children" | "onSelect"
> & {
label?: string
placeholder?: string
items?: Autocomplete006Item[]
defaultQuery?: string
onSelect?: (title: string) => void
accent?: string
}
// Идея компонента: подсказка не строкой, а карточкой товара. Складской поиск
// по одному названию бесполезен: «кабель» найдётся сорок раз, выбирают по
// артикулу, цене и остатку. Поэтому строка держит три поля, а нулевой остаток
// подсвечен — его нельзя продать, но можно заказать.
const STYLES = `
:where([data-vibeui-block="autocomplete-006"]){
--vibeui-autocomplete-006-bg:oklch(1 0 0);
--vibeui-autocomplete-006-fg:oklch(0.22 0.014 265);
--vibeui-autocomplete-006-muted:oklch(0.52 0.014 265);
--vibeui-autocomplete-006-border:oklch(0.9 0.006 265);
--vibeui-autocomplete-006-field:oklch(0.985 0.002 265);
--vibeui-autocomplete-006-active:oklch(0.95 0.02 265);
--vibeui-autocomplete-006-accent:oklch(0.55 0.17 265);
--vibeui-autocomplete-006-warn:oklch(0.58 0.17 30);
--vibeui-autocomplete-006-radius:0.625rem;
--vibeui-autocomplete-006-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="autocomplete-006"]{
display:flex;flex-direction:column;gap:0.375rem;
width:100%;max-width:24rem;box-sizing:border-box;padding:0.875rem;
background:var(--vibeui-autocomplete-006-bg);
border:1px solid var(--vibeui-autocomplete-006-border);
border-radius:calc(var(--vibeui-autocomplete-006-radius) + 0.25rem);
color:var(--vibeui-autocomplete-006-fg);
font-family:var(--vibeui-autocomplete-006-font);
}
[data-vibeui-block="autocomplete-006"] label{font-size:0.8125rem;font-weight:600}
[data-vibeui-block="autocomplete-006"] input{
box-sizing:border-box;width:100%;height:2.5rem;padding:0 0.75rem;
border:1px solid var(--vibeui-autocomplete-006-border);
border-radius:var(--vibeui-autocomplete-006-radius);
background:var(--vibeui-autocomplete-006-field);
color:inherit;font:inherit;font-size:0.875rem;
}
[data-vibeui-block="autocomplete-006"] input::placeholder{color:var(--vibeui-autocomplete-006-muted)}
[data-vibeui-block="autocomplete-006"] input:focus-visible{
outline:2px solid var(--vibeui-autocomplete-006-accent);outline-offset:1px;border-color:transparent;
}
[data-vibeui-block="autocomplete-006"] [data-part="list"]{
margin:0;padding:0.25rem;list-style:none;max-height:14rem;overflow-y:auto;
border:1px solid var(--vibeui-autocomplete-006-border);
border-radius:var(--vibeui-autocomplete-006-radius);
background:var(--vibeui-autocomplete-006-bg);
}
/* Строка в две колонки: слева название и артикул, справа цена и остаток. */
[data-vibeui-block="autocomplete-006"] [data-part="option"]{
display:grid;grid-template-columns:1fr auto;align-items:center;gap:0.25rem 0.75rem;
padding:0.4375rem 0.5rem;border-radius:0.4375rem;cursor:pointer;
}
[data-vibeui-block="autocomplete-006"] [data-part="option"]:hover{background:var(--vibeui-autocomplete-006-active)}
[data-vibeui-block="autocomplete-006"] [data-part="title"]{font-size:0.875rem;line-height:1.3}
[data-vibeui-block="autocomplete-006"] [data-part="price"]{font-size:0.875rem;font-weight:650;font-variant-numeric:tabular-nums}
[data-vibeui-block="autocomplete-006"] [data-part="meta"]{grid-column:1;font-size:0.75rem;color:var(--vibeui-autocomplete-006-muted)}
[data-vibeui-block="autocomplete-006"] [data-part="stock"]{grid-column:2;justify-self:end;font-size:0.75rem;color:var(--vibeui-autocomplete-006-muted);font-variant-numeric:tabular-nums}
[data-vibeui-block="autocomplete-006"] [data-part="stock"][data-empty="true"]{color:var(--vibeui-autocomplete-006-warn)}
[data-vibeui-block="autocomplete-006"] [data-part="empty"]{padding:0.75rem 0.5rem;font-size:0.8125rem;color:var(--vibeui-autocomplete-006-muted)}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="autocomplete-006"] *{animation:none!important;transition:none!important}}
`
const DEFAULT_ITEMS: Autocomplete006Item[] = [
{
title: "Кабель USB-C / USB-C, 1 м",
meta: "Артикул 41-208",
price: "790 ₽",
stock: 34,
},
{
title: "Кабель USB-C / Lightning, 2 м",
meta: "Артикул 41-311",
price: "1 290 ₽",
stock: 6,
},
{
title: "Кабель HDMI 2.1, 3 м",
meta: "Артикул 52-104",
price: "2 450 ₽",
stock: 0,
},
{
title: "Кабель Ethernet Cat 6, 5 м",
meta: "Артикул 63-770",
price: "990 ₽",
stock: 118,
},
]
/**
* Подсказка карточкой: название, артикул, цена и остаток в одной строке.
* Один файл, ноль зависимостей, собственная палитра.
*/
export function Autocomplete006({
label = "Товар",
placeholder = "Название или артикул",
items = DEFAULT_ITEMS,
defaultQuery = "кабель",
onSelect,
accent,
className,
style,
...props
}: Autocomplete006Props) {
const id = useId()
const [query, setQuery] = useState(defaultQuery)
const matches = useMemo(() => {
const needle = query.trim().toLowerCase()
if (!needle) return items
return items.filter((item) =>
`${item.title} ${item.meta}`.toLowerCase().includes(needle),
)
}, [items, query])
const palette = {
...(accent ? { "--vibeui-autocomplete-006-accent": accent } : null),
...style,
} as CSSProperties
return (
<>
<style href="vibeui-autocomplete-006" precedence="medium">
{STYLES}
</style>
<div
{...props}
data-vibeui-block="autocomplete-006"
className={className}
style={palette}
>
<label htmlFor={id}>{label}</label>
<input
id={id}
type="search"
role="combobox"
autoComplete="off"
placeholder={placeholder}
value={query}
aria-expanded={matches.length > 0}
aria-controls={`${id}-list`}
aria-autocomplete="list"
onChange={(event) => setQuery(event.target.value)}
/>
<ul
id={`${id}-list`}
role="listbox"
aria-label={label}
data-part="list"
>
{matches.map((item) => (
<li
key={item.meta}
role="option"
aria-selected="false"
data-part="option"
onMouseDown={(event) => {
event.preventDefault()
setQuery(item.title)
onSelect?.(item.title)
}}
>
<span data-part="title">{item.title}</span>
<span data-part="price">{item.price}</span>
<span data-part="meta">{item.meta}</span>
<span data-part="stock" data-empty={item.stock === 0}>
{item.stock === 0 ? "нет в наличии" : `${item.stock} шт`}
</span>
</li>
))}
{matches.length === 0 ? (
<li data-part="empty" role="presentation">
По запросу ничего не нашлось
</li>
) : null}
</ul>
</div>
</>
)
}