Buttons
Quantity Stepper
A quantity stepper: two buttons around a real input — typing "12" beats pressing plus twelve times.
- button
- stepper
- quantity
- form
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/button-018?lang=en
pcs
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 "button-018" (Quantity Stepper) 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/button-018.json
Registry item: https://vibeui.ru/r/button-018.json
Installs to: components/vibeui/button-018.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 quantity stepper: two buttons around a real input — typing "12" beats pressing plus twelve times.
A quantity stepper: minus, a number input and plus, with the buttons disabled at the range edges and a unit label. Zero dependencies, one file.
## 3. How to use it
import { Button018 } from "@/components/vibeui/button-018"
<Button018 defaultValue={2} min={1} max={20} onChange={setQty} />
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-button-018-* palette — do not swap it for your theme tokens
- the real input in the middle: twenty plus presses is not a workflow
- disabling the buttons at the edges instead of silently doing nothing
- the aria-label carrying the next value: a bare "minus" tells a screen reader nothing
- tabular figures so the field does not jitter
- hiding the native number spinners: custom buttons already sit beside them
## 6. You may change
- defaultValue, min, max and step
- label — the field's name
- unit — the measurement unit
- the onChange handler
## 7. Rules
- The value is clamped on every input: an empty field becomes the minimum.
- A stepper is wrong for large numbers: hundreds want a plain field.
- Removing an item from a cart is not "minus to zero": give it its own action.
- 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/button-018.jsonhttps://vibeui.ru/r/button-018.jsonКомпонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-button-018-*. Клиентский: "use client". Значение живёт в input type="number" со скрытой подписью через useId; стрелки браузера убраны, потому что рядом стоят собственные кнопки. На границах диапазона кнопки disabled, а их aria-label содержит будущее значение.
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 Button018Props = Omit<
ComponentPropsWithoutRef<"div">,
"children" | "onChange" | "defaultValue"
> & {
defaultValue?: number
min?: number
max?: number
step?: number
label?: string
unit?: string
onChange?: (value: number) => void
}
// Идея компонента: пара кнопок вокруг числа. Само число — поле ввода, а не
// текст: набрать «12» быстрее, чем нажать плюс двенадцать раз. Кнопки
// гаснут на границах диапазона, а не молча ничего не делают, и у каждой своё
// имя со значением — «минус» без контекста скринридеру бесполезен.
const STYLES = `
:where([data-vibeui-block="button-018"]){
--vibeui-button-018-fg:oklch(0.3 0.014 265);
--vibeui-button-018-muted:oklch(0.55 0.014 265);
--vibeui-button-018-bg:oklch(1 0 0);
--vibeui-button-018-border:oklch(0.9 0.006 265);
--vibeui-button-018-hover:oklch(0.96 0.004 265);
--vibeui-button-018-accent:oklch(0.55 0.17 265);
--vibeui-button-018-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="button-018"]{
display:inline-flex;align-items:center;
height:2.25rem;box-sizing:border-box;
border:1px solid var(--vibeui-button-018-border);border-radius:0.625rem;
background:var(--vibeui-button-018-bg);color:var(--vibeui-button-018-fg);
font-family:var(--vibeui-button-018-font);
}
[data-vibeui-block="button-018"] button{
appearance:none;border:0;cursor:pointer;background:transparent;
display:inline-flex;align-items:center;justify-content:center;flex:none;
width:2.125rem;height:100%;padding:0;color:inherit;border-radius:0.5rem;
}
[data-vibeui-block="button-018"] button:hover:not(:disabled){background:var(--vibeui-button-018-hover)}
[data-vibeui-block="button-018"] button:focus-visible{outline:2px solid var(--vibeui-button-018-accent);outline-offset:-2px}
/* На границе диапазона кнопка гаснет: молчаливое бездействие путает. */
[data-vibeui-block="button-018"] button:disabled{cursor:not-allowed;opacity:.35}
[data-vibeui-block="button-018"] [data-part="sign"]{position:relative;width:0.75rem;height:0.75rem}
[data-vibeui-block="button-018"] [data-part="sign"]::before{
content:"";position:absolute;left:50%;top:50%;width:0.6875rem;height:1.5px;
margin:-0.75px 0 0 -0.34375rem;background:currentColor;border-radius:9999px;
}
[data-vibeui-block="button-018"] [data-plus="true"]::after{
content:"";position:absolute;left:50%;top:50%;width:1.5px;height:0.6875rem;
margin:-0.34375rem 0 0 -0.75px;background:currentColor;border-radius:9999px;
}
/* Число — поле: набрать «12» быстрее, чем нажать плюс двенадцать раз. */
[data-vibeui-block="button-018"] input{
width:2.5rem;height:100%;box-sizing:border-box;padding:0;
border:0;border-left:1px solid var(--vibeui-button-018-border);
border-right:1px solid var(--vibeui-button-018-border);
background:transparent;color:inherit;
font:inherit;font-size:0.875rem;font-weight:650;text-align:center;
font-variant-numeric:tabular-nums;
-moz-appearance:textfield;
}
[data-vibeui-block="button-018"] input::-webkit-outer-spin-button,
[data-vibeui-block="button-018"] input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}
[data-vibeui-block="button-018"] input:focus-visible{outline:2px solid var(--vibeui-button-018-accent);outline-offset:-2px}
[data-vibeui-block="button-018"] [data-part="unit"]{
padding:0 0.625rem;font-size:0.75rem;color:var(--vibeui-button-018-muted);
}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="button-018"] *{animation:none!important;transition:none!important}}
`
/**
* Счётчик количества: две кнопки вокруг настоящего поля ввода.
* Один файл, ноль зависимостей, собственная палитра.
*/
export function Button018({
defaultValue = 2,
min = 1,
max = 20,
step = 1,
label = "Количество",
unit = "шт",
onChange,
className,
style,
...props
}: Button018Props) {
const id = useId()
const [value, setValue] = useState(defaultValue)
const update = (next: number) => {
const safe = Math.min(max, Math.max(min, next))
setValue(safe)
onChange?.(safe)
}
return (
<>
<style href="vibeui-button-018" precedence="medium">
{STYLES}
</style>
<div
{...props}
data-vibeui-block="button-018"
className={className}
style={style as CSSProperties}
>
<button
type="button"
aria-label={`Уменьшить до ${Math.max(min, value - step)}`}
disabled={value <= min}
onClick={() => update(value - step)}
>
<span data-part="sign" aria-hidden="true" />
</button>
<label htmlFor={id} hidden>
{label}
</label>
<input
id={id}
type="number"
inputMode="numeric"
min={min}
max={max}
step={step}
value={value}
onChange={(event) => update(Number(event.target.value) || min)}
/>
<button
type="button"
aria-label={`Увеличить до ${Math.min(max, value + step)}`}
disabled={value >= max}
onClick={() => update(value + step)}
>
<span data-part="sign" data-plus="true" aria-hidden="true" />
</button>
{unit ? <span data-part="unit">{unit}</span> : null}
</div>
</>
)
}