Number Input (Quantity Stepper) new 数字输入框(数量加减器) web

Linen shirt¥189

标本可交互,可以直接操作。

Anatomy — every part, named解剖 —— 每个部件的名字

  1. 1 Decrement减号 button

    Minus button, disabled at the minimum.

    减少按钮,到最小值时禁用。

    Prompt fragmentPrompt 片段

    the minus button, disabled at the minimum

    减号按钮,到最小值时禁用

  2. 2 Value field数值框 inputmode=numeric

    Shows the number and accepts typing or arrow keys.

    显示数字,可以直接输入或用方向键调整。

    Prompt fragmentPrompt 片段

    the value field that accepts typing and arrow keys

    可输入、可用方向键调整的数值框

  3. 3 Increment加号 button

    Plus button, disabled at the maximum.

    增加按钮,到最大值时禁用。

    Prompt fragmentPrompt 片段

    the plus button, disabled at the maximum

    加号按钮,到最大值时禁用

  4. 4 Limit hint限制提示 aria-live

    States the limit and explains any correction.

    说明上限,并解释每一次自动修正。

    Prompt fragmentPrompt 片段

    a hint line stating the limit and explaining corrections

    写明上限并解释修正原因的提示行

Prompt — paste into your agentPrompt —— 直接粘贴给你的代理

Build a quantity number input: a text field with inputmode numeric between a minus and a plus button; clamp every change from buttons, Up/Down keys and typing to min 1 and max 5 with step 1; disable the button at each bound; strip non-digits while typing and clamp on blur or Enter; when a typed value is out of range, correct it and say why in a hint line; expose role spinbutton with aria-valuemin, max and now.

做一个数量输入框:中间是 inputmode=numeric 的文本框,两侧是减号和加号按钮;按钮、上下方向键和手动输入都统一限制在最小 1、最大 5、步长 1;到上下限时对应按钮禁用;输入时去掉非数字,失焦或回车时再校正;输入超出范围时自动修正,并在提示行说明原因;提供 role=spinbutton 以及 aria-valuemin、max、now。

Debug prompt — when it misbehaves调试 Prompt —— 当它不听话时

Debug my number input. Check that buttons, arrow keys and typed input all go through one clamp; the minus and plus buttons disable exactly at the bounds; typing is not blocked mid-edit but is validated on blur; out-of-range input is corrected with a visible reason; the value cannot become empty or NaN; and screen readers get role spinbutton with current, min and max values. The symptom:

调试我的数字输入框。检查:按钮、方向键和手动输入是否都经过同一个范围限制;减号和加号是否恰好在上下限禁用;输入过程中不拦截、失焦时再校验;超出范围时是否修正并显示原因;数值是否可能变成空或 NaN;以及读屏是否能读到 spinbutton 的当前值、最小值和最大值。症状是:

In code代码里叫什么

Framework框架Symbol符号Note说明
HTML <input type="number" min max step> the native numeric input with spinner arrows原生数字输入框,自带上下箭头
ARIA role="spinbutton" + aria-valuenow for custom steppers built from a text field and buttons用文本框加按钮自己做时的读屏语义
HTML inputmode="numeric" a number keypad on phones without the native spinner手机上弹出数字键盘,又没有原生小箭头

See also相关词条

我的参考集

组合知名网站、UI 元素、视觉风格和平面设计案例,导出给 AI。

你的下一份设计,从这里开始。

在任意案例旁点击「加入参考」,就能把品牌、组件、风格和平面设计案例组合成一份 AI 设计说明。

搜索参考库Search the library

输入关键词,搜索所有参考。