Saltar al contenido
El Muestrario

componente · @solu30/ui-kit/input

QuantityUnitField

El componente, montado

Cargando el espécimen…

Cargando el chunk del paquete instalado…

De dónde se importa

import { QuantityUnitField } from '@solu30/ui-kit/input'

Props

11 props declaradas en los tipos de la versión instalada.
PropRequeridaTipoQué hace
valuestring | null | undefinedCurrent numeric value as string (e.g. "500", "1.5"). Pass null or undefined to render an empty field.
unitstringCurrently selected unit string (e.g. "g", "kg", "ml", "L", "u"). Must match one of the rendered options; if not, the browser will default to the first option.
familyopcionalUnitFamily | nullRestricts the unit dropdown to a physical domain. "weight" → g, kg "volume" → ml, L "discrete" → u null → all units (no restriction)
allowedUnitsopcionalUnitOption[]Explicit unit options. When provided, takes precedence over `family`. Use this to override the family-derived list (e.g. vertical-specific units).
onChange(value: string | null, unit: string) => voidCalled whenever the numeric value or the unit changes. `value` is null when the field is cleared (empty string input).
disabledopcionalboolean
placeholderopcionalstringPlaceholder for the numeric input. Default: "0"
idopcionalstringHTML id for the numeric input (for <label htmlFor> association).
ariaLabelopcionalstringaria-label for the numeric input. Default: "Cantidad"
sizeopcional"sm" | "md"
classNameopcionalstring

Ejemplo del paquete

// Unrestricted (all units)
<QuantityUnitField value={qty} unit={unit} onChange={(v, u) => setState(v, u)} />
// Restricted to weight family (g / kg)
<QuantityUnitField value={qty} unit={unit} family="weight" onChange={...} />
// Explicit allowed units
<QuantityUnitField value={qty} unit={unit}
allowedUnits={[{ value: "kg", label: "kg" }]} onChange={...} />

Del @example del JSDoc de @solu30/ui-kit, sin editar. Cuatro de los 69 ejemplos del paquete traen pegada la firma cruda del .d.ts —el mismo defecto del extractor que se come las descripciones—, y por eso la caja tiene tope de alto: el ejemplo de verdad suele estar al final.