Quantity: 3 / 10
Instalación
npx logic2b@next add number-fieldUso
import { NumberField } from "@/components/ui/number-field"
<NumberField defaultValue={1} min={0} max={10} />
Controlado:
const [value, setValue] = React.useState(3)
<NumberField value={value} onValueChange={setValue} min={0} max={10} />
Genera un <input type="number"> real, por lo que admite el envío nativo de
formularios y la introducción mediante teclado. Los controles propios del
navegador se ocultan en favor de los botones con estilo, que se desactivan al
alcanzar los límites min y max.
Ejemplos
Paso
Playground interactivo
Edita las propiedades del componente y revisa el JSX exacto antes de copiarlo. La vista previa se carga solo cuando esta sección entra en pantalla.
<NumberField
defaultValue={3}
min={0}
max={12}
step={1}
aria-label="Quantity"
/>Referencia de API
Generada a partir de las exportaciones públicas de TypeScript en src/ui/number-field.tsx. Las descripciones técnicas conservan el texto canónico del código fuente.
NumberFieldProps
Tipointerface NumberFieldProps extends Omit< React.ComponentProps<"input">, "value" | "defaultValue" | "onChange" | "type" > { value?: number defaultValue?: number onValueChange?: (value: number) => void min?: number max?: number step?: number }NumberField
ComponenteA numeric input with decrement/increment steppers, min/max clamping and step. Controlled via `value`/`onValueChange` or uncontrolled via `defaultValue`. Renders a real `<input type="number">` so native form submission and keyboard work; the native spinners are hidden in favor of the styled buttons.
Props: NumberFieldProps| Propiedad | Tipo | Obligatoria | Valor predeterminado | Descripción |
|---|---|---|---|---|
value | number | No | — | — |
defaultValue | number | No | — | — |
onValueChange | (value: number) => void | No | — | — |
min | number | No | — | — |
max | number | No | — | — |
step | number | No | 1 | — |
Contrato de accesibilidad
Comportamiento legible por máquinas y responsabilidades de quien integra number-field. Los detalles normativos conservan el texto canónico del registro.
- Soporte
- Semántica nativa
- Patrón
- spinbutton
- HTMLInputElement type=number
| Teclas | Comportamiento |
|---|---|
| ArrowUp ArrowDown ArrowLeft ArrowRight | Move within the composite control. |
| Enter | Commit typed input according to native number-field behavior. |
Semántica incorporada
- The input retains native spinbutton semantics; step buttons are native buttons with labels.
Responsabilidades de integración
- Associate the input with a label and communicate min/max constraints in visible help text.