Inputs
Icon Trigger Select
A select showing the icon of the chosen option: the trigger is ours, while the list is opened by a native select lying on top of it as a transparent layer.
- select
- icon
- form
- native
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/select-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 "select-003" (Icon Trigger 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-003.json
Registry item: https://vibeui.ru/r/select-003.json
Installs to: components/vibeui/select-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 select showing the icon of the chosen option: the trigger is ours, while the list is opened by a native select lying on top of it as a transparent layer.
A select with a custom trigger and the chosen option's icon over a native list. One file, zero dependencies, a client component.
## 3. How to use it
import { Select003 } from "@/components/vibeui/select-003"
<Select003
label="Payment method"
defaultValue="invoice"
/>
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-003-* palette — do not swap it for your theme tokens
- the transparent select over the trigger: it is the mechanism — a hand-made menu loses the keyboard and the system list on phones
- aria-hidden on the trigger: otherwise a screen reader reads the text twice, from the button and from the select
- the highlight driven by select:focus: without it the trigger looks the same focused and not
- the component's own light surface — without it the dark text disappears on a dark page
- the node order select → trigger → arrow: the adjacent combinator in the CSS depends on it
## 6. You may change
- the field caption through label
- the set of choices and their icons through options
- the initial value through defaultValue
- the accent colour through accent
## 7. Rules
- The icon is a character in text: for real artwork replace the string in options with your own node, but keep the file self-contained.
- The transparent select catches every click on the trigger — do not attach handlers to the trigger, they will not fire.
- A long caption is cut with an ellipsis: the trigger column is fixed so the tile does not stretch.
- 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-003.jsonhttps://vibeui.ru/r/select-003.jsonКлиентский компонент: useState хранит выбранное значение, чтобы обновлять иконку и подпись в кнопке. Настоящий <select> растянут на всю область триггера через position:absolute;inset:0 и opacity:0 — клик, клавиатура и системный список остаются браузерными, оформление наше. Триггер помечен aria-hidden, потому что доступное имя и значение уже несёт сам select. Фокус ловится правилом select:focus + [data-part=trigger]. Палитра в --vibeui-select-003-*.
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 Select003Option = {
value: string
label: string
icon: string
}
export type Select003Props = Omit<
ComponentPropsWithoutRef<"div">,
"children" | "onChange"
> & {
label?: string
options?: Select003Option[]
defaultValue?: string
accent?: string
}
// Идея компонента: витрина от кастомной кнопки, механика от нативного select.
// Самодельное меню пришлось бы учить клавиатуре, прокрутке и телефону,
// поэтому настоящий <select> лежит прозрачным слоем поверх кнопки: система
// открывает свой список, а мы рисуем плитку с иконкой выбранного варианта.
const STYLES = `
:where([data-vibeui-block="select-003"]){
--vibeui-select-003-surface:oklch(1 0 0);
--vibeui-select-003-surface-border:oklch(0.91 0.006 265);
--vibeui-select-003-fg:oklch(0.23 0.016 265);
--vibeui-select-003-muted:oklch(0.55 0.014 265);
--vibeui-select-003-border:oklch(0.87 0.008 265);
--vibeui-select-003-accent:oklch(0.58 0.16 155);
--vibeui-select-003-tint:oklch(0.58 0.16 155 / 12%);
--vibeui-select-003-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="select-003"]{
display:flex;flex-direction:column;gap:0.375rem;
width:100%;max-width:20rem;box-sizing:border-box;padding:0.875rem;
background:var(--vibeui-select-003-surface);
border:1px solid var(--vibeui-select-003-surface-border);border-radius:0.875rem;
font-family:var(--vibeui-select-003-font);color:var(--vibeui-select-003-fg);
}
[data-vibeui-block="select-003"] [data-part="label"]{font-size:0.8125rem;font-weight:600}
[data-vibeui-block="select-003"] [data-part="field"]{position:relative;display:block}
/* Настоящий select лежит поверх кнопки и невидим: клик, клавиатура и
системный список остаются браузерными, оформление — наше. */
[data-vibeui-block="select-003"] select{
position:absolute;inset:0;width:100%;height:100%;
opacity:0;cursor:pointer;font:inherit;
}
[data-vibeui-block="select-003"] [data-part="trigger"]{
display:flex;align-items:center;gap:0.625rem;
box-sizing:border-box;width:100%;min-height:3rem;padding:0.5rem 2.25rem 0.5rem 0.5rem;
border:1px solid var(--vibeui-select-003-border);border-radius:0.75rem;
transition:border-color .16s ease,box-shadow .16s ease;
}
[data-vibeui-block="select-003"] select:focus-visible + [data-part="trigger"],
[data-vibeui-block="select-003"] select:focus + [data-part="trigger"]{
border-color:var(--vibeui-select-003-accent);
box-shadow:0 0 0 3px color-mix(in oklab,var(--vibeui-select-003-accent) 22%,transparent);
}
[data-vibeui-block="select-003"] [data-part="icon"]{
display:grid;place-items:center;flex:none;
width:2rem;height:2rem;border-radius:0.5rem;
background:var(--vibeui-select-003-tint);font-size:1rem;line-height:1;
}
[data-vibeui-block="select-003"] [data-part="text"]{
flex:1 1 auto;min-width:0;font-size:0.9375rem;
overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
}
[data-vibeui-block="select-003"] [data-part="arrow"]{
position:absolute;right:0.875rem;top:50%;
width:0.4375rem;height:0.4375rem;margin-top:-0.3125rem;pointer-events:none;
border-right:1.5px solid var(--vibeui-select-003-muted);
border-bottom:1.5px solid var(--vibeui-select-003-muted);
transform:rotate(45deg);
}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="select-003"] *{animation:none!important;transition:none!important}}
`
const DEFAULT_OPTIONS: Select003Option[] = [
{ value: "card", label: "Банковская карта", icon: "💳" },
{ value: "invoice", label: "Счёт для юрлица", icon: "🧾" },
{ value: "crypto", label: "Криптокошелёк", icon: "🪙" },
{ value: "cash", label: "Наличные курьеру", icon: "💵" },
]
/**
* Select с иконкой выбранного варианта: своя кнопка, системный список.
* Один файл, ноль зависимостей, собственная палитра.
*/
export function Select003({
label = "Способ оплаты",
options = DEFAULT_OPTIONS,
defaultValue = "card",
accent,
className,
style,
...props
}: Select003Props) {
const id = useId()
const [value, setValue] = useState(defaultValue)
const current = options.find((option) => option.value === value) ?? options[0]
const palette = {
...(accent ? { "--vibeui-select-003-accent": accent } : null),
...style,
} as CSSProperties
return (
<>
<style href="vibeui-select-003" precedence="medium">
{STYLES}
</style>
<div
{...props}
data-vibeui-block="select-003"
className={className}
style={palette}
>
<label data-part="label" htmlFor={id}>
{label}
</label>
<span data-part="field">
<select
id={id}
value={value}
onChange={(event) => setValue(event.target.value)}
>
{options.map((option) => (
<option key={option.value} value={option.value}>
{option.label}
</option>
))}
</select>
<span data-part="trigger" aria-hidden="true">
<span data-part="icon">{current?.icon}</span>
<span data-part="text">{current?.label}</span>
</span>
<span data-part="arrow" aria-hidden="true" />
</span>
</div>
</>
)
}