Inputs

Currency Select

An amount with the currency picked inside the same field: the sign on the left follows the choice, so the line always reads as one value.

  • currency
  • money
  • select
  • form

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/currency-002?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 "currency-002" (Currency 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/currency-002.json

Registry item: https://vibeui.ru/r/currency-002.json
Installs to: components/vibeui/currency-002.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
An amount with the currency picked inside the same field: the sign on the left follows the choice, so the line always reads as one value.

An amount field with a built-in currency picker: the leading sign and the caption follow the selected code. Zero dependencies, one file.

## 3. How to use it
import { Currency002 } from "@/components/vibeui/currency-002"

<Currency002 label="Invoice amount" defaultValue={1200} defaultCurrency="EUR" />

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-currency-002-* palette — do not swap it for your theme tokens
- its own light surface: the field gets shown over any background
- the currency inside the field frame: a separate control above reads as a second question
- the native select: it hands over first-letter search and a phone wheel picker for free
- the sign to the left of the number: "€ 1,200" reads as one line while a trailing sign detaches
- the aria-label on the currency list: it has no visible caption next to it
- the live region under the field: its text changes together with the currency

## 6. You may change
- label — the field caption
- currencies — the currency list, their signs and word forms
- defaultValue and defaultCurrency — the starting amount and currency
- the caption text under the field
- the accent through the accent prop

## 7. Rules
- The amount is deliberately not converted on a currency change: this is invoice entry, not a converter.
- Currency signs differ in width — the field must not jump, hence the fixed padding on the sign.
- Emit the amount and the code together, or the receiving side cannot tell the currency.
- 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/currency-002.json
https://vibeui.ru/r/currency-002.json

Компонент самодостаточен: один файл, ноль зависимостей, палитра в локальных переменных --vibeui-currency-002-*. Клиентский: сумма и код валюты в состоянии. Список валют вынесен не над полем, а внутрь общей рамки: сумма в валюте — одно значение, а отдельный контрол читается как второй вопрос. Список нативный, поэтому даёт поиск по первой букве на десктопе и системное колесо на телефоне без единой строки кода. Знак валюты стоит слева от числа и меняется вместе с выбором.

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 Currency002Props = Omit<
  ComponentPropsWithoutRef<"div">,
  "children" | "defaultValue" | "onChange"
> & {
  label?: string
  defaultValue?: number
  defaultCurrency?: string
  currencies?: { code: string; sign: string; text: string }[]
  accent?: string
}

// Идея компонента: валюта выбирается прямо в поле суммы. Отдельный список над
// полем читается как второй вопрос, хотя это одно значение — сумма в валюте.
// Знак валюты стоит слева от числа и меняется вместе с выбором, поэтому строка
// всегда читается целиком: «€ 1 200». Список нативный: он даёт поиск по первой
// букве, а на телефоне — системное колесо, и всё это без единой строки кода.
const STYLES = `
:where([data-vibeui-block="currency-002"]){
--vibeui-currency-002-surface:oklch(1 0 0);
--vibeui-currency-002-field:oklch(0.985 0.002 265);
--vibeui-currency-002-shell:oklch(0.9 0.006 265);
--vibeui-currency-002-fg:oklch(0.22 0.014 265);
--vibeui-currency-002-muted:oklch(0.55 0.014 265);
--vibeui-currency-002-border:oklch(0.88 0.008 265);
--vibeui-currency-002-accent:oklch(0.52 0.16 255);
--vibeui-currency-002-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
/* Своя светлая подложка: поле показывают поверх любого фона. */
[data-vibeui-block="currency-002"]{
display:flex;flex-direction:column;gap:0.5rem;
width:100%;max-width:20rem;box-sizing:border-box;padding:0.875rem;
background:var(--vibeui-currency-002-surface);
border:1px solid var(--vibeui-currency-002-shell);border-radius:0.875rem;
font-family:var(--vibeui-currency-002-font);color:var(--vibeui-currency-002-fg);
}
[data-vibeui-block="currency-002"] label{font-size:0.8125rem;font-weight:650}
[data-vibeui-block="currency-002"] [data-part="row"]{
display:flex;align-items:stretch;overflow:hidden;
border:1px solid var(--vibeui-currency-002-border);border-radius:0.75rem;
background:var(--vibeui-currency-002-field);
}
[data-vibeui-block="currency-002"] [data-part="row"]:focus-within{
border-color:var(--vibeui-currency-002-accent);
box-shadow:0 0 0 2px oklch(0.52 0.16 255 / 18%);
}
/* Знак слева от числа: строка читается целиком, «€ 1 200». */
[data-vibeui-block="currency-002"] [data-part="sign"]{
display:flex;align-items:center;flex:none;padding:0 0.25rem 0 0.875rem;
font-size:1.25rem;font-weight:700;color:var(--vibeui-currency-002-muted);
}
[data-vibeui-block="currency-002"] input{
flex:1 1 auto;min-width:0;width:100%;
appearance:none;border:0;background:none;outline:none;
height:3rem;padding:0 0.5rem;color:inherit;
font:inherit;font-size:1.25rem;font-weight:700;
font-variant-numeric:tabular-nums;
}
[data-vibeui-block="currency-002"] input::-webkit-outer-spin-button,
[data-vibeui-block="currency-002"] input::-webkit-inner-spin-button{appearance:none;margin:0}
/* Валюта в том же поле: это одно значение, а не второй вопрос. */
[data-vibeui-block="currency-002"] select{
flex:none;appearance:none;cursor:pointer;
padding:0 0.875rem;border:0;border-left:1px solid var(--vibeui-currency-002-border);
background:var(--vibeui-currency-002-surface);color:inherit;
font:inherit;font-size:0.875rem;font-weight:700;letter-spacing:0.02em;
}
[data-vibeui-block="currency-002"] select:focus-visible{outline:2px solid var(--vibeui-currency-002-accent);outline-offset:-2px}
[data-vibeui-block="currency-002"] [data-part="hint"]{
margin:0;font-size:0.75rem;line-height:1.4;color:var(--vibeui-currency-002-muted);
}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="currency-002"] *{animation:none!important;transition:none!important}}
`

const DEFAULT_CURRENCIES = [
  { code: "RUB", sign: "₽", text: "рублях" },
  { code: "USD", sign: "$", text: "долларах" },
  { code: "EUR", sign: "€", text: "евро" },
  { code: "CNY", sign: "¥", text: "юанях" },
]

/**
 * Сумма с выбором валюты в том же поле: знак слева меняется вместе с выбором.
 * Один файл, ноль зависимостей, собственная палитра.
 */
export function Currency002({
  label = "Сумма счёта",
  defaultValue = 1200,
  defaultCurrency = "EUR",
  currencies = DEFAULT_CURRENCIES,
  accent,
  className,
  style,
  ...props
}: Currency002Props) {
  const id = useId()
  const [amount, setAmount] = useState(defaultValue)
  const [code, setCode] = useState(defaultCurrency)
  const active = currencies.find((item) => item.code === code) ?? currencies[0]

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

  return (
    <>
      <style href="vibeui-currency-002" precedence="medium">
        {STYLES}
      </style>
      <div
        {...props}
        data-vibeui-block="currency-002"
        className={className}
        style={palette}
      >
        <label htmlFor={id}>{label}</label>
        <div data-part="row">
          <span data-part="sign" aria-hidden="true">
            {active.sign}
          </span>
          <input
            id={id}
            type="number"
            inputMode="decimal"
            min={0}
            step={1}
            value={amount}
            aria-describedby={`${id}-hint`}
            onChange={(event) => {
              const next = Number(event.target.value)
              setAmount(Number.isFinite(next) ? Math.max(0, next) : 0)
            }}
          />
          <select
            value={code}
            aria-label="Валюта счёта"
            onChange={(event) => setCode(event.target.value)}
          >
            {currencies.map((item) => (
              <option key={item.code} value={item.code}>
                {item.code}
              </option>
            ))}
          </select>
        </div>
        <p id={`${id}-hint`} data-part="hint" aria-live="polite">
          Счёт будет выставлен в {active.text}
        </p>
      </div>
    </>
  )
}