NumberField
Com rótulo
De 1 a 12, sem juros.
Desabilitado
import { NumberField } from '@rivocode/ui'Quando usar
Campo de número com mais e menos.
Use quando o valor tem passo e limite conhecidos: quantidade, parcelas, dias de
prazo. Para dinheiro, o MaskedInput com molde de moeda diz mais, porque ali o
que importa e a pontuacao e não o passo.
O Input cru continua servindo para número solto. A diferença aqui e que seta
do teclado, rolagem e os botões respeitam min, max e step, o campo nunca
chega num valor que o formulário rejeita depois.
<Field>
<FieldLabel>Parcelas</FieldLabel>
<NumberField defaultValue={3} min={1} max={12} />
<FieldDescription>De 1 a 12, sem juros.</FieldDescription>
</Field>
No React Native
Traduz: o @rivocode/ui-native exporta NumberField - vira stepper (menos, valor, mais), que é o idioma do toque. A API não é a mesma do web (no nativo tudo é controlado), e a tabela de paridade diz o que muda peça a peça.
API
| Prop | Tipo |
|---|---|
allowOutOfRange0.4.0When true, direct text entry may be outside the `min`/`max` range without clamping, so native range underflow/overflow validation can occur. | boolean |
allowWheelScrub0.4.0Whether to allow the user to scrub the input value with the mouse wheel while focused and hovering over the input. | boolean |
defaultValue0.4.0The uncontrolled value of the field when it's initially rendered. | number |
disabled0.4.0Whether the component should ignore user interaction. | boolean |
form0.4.0Identifies the form that owns the hidden input. | string |
inputRef0.4.0A ref to access the hidden input element. | Ref<HTMLInputElement> |
largeStep0.4.0The large step value of the input element when incrementing while the shift key is held. | number |
locale0.4.0The locale of the input element. | LocalesArgument |
max0.4.0The maximum value of the input element. | number |
min0.4.0The minimum value of the input element. | number |
name0.4.0Identifies the field when a form is submitted. | string |
numberFormat0.5.0As opcoes do `Intl.NumberFormat`. | NumberFormatOptions |
onValueChange0.4.0Callback fired when the number value changes. | ((value: number | null, eventDetails: NumberFieldRootChangeEventDetails) => void) |
onValueCommitted0.4.0Callback function that is fired when the value is committed. | ((value: number | null, eventDetails: NumberFieldRootCommitEventDetails) => void) |
placeholder0.4.0 | string |
readOnly0.4.0Whether the user should be unable to change the field value. | boolean |
render0.4.0Allows you to replace the component's HTML element with a different tag, or compose it with another component. | ComponentRenderFn<HTMLProps, NumberFieldRootState>ReactElement<unknown, stringJSXElementConstructor<any>> |
required0.4.0Whether the user must enter a value before submitting a form. | boolean |
size0.4.0 | "lg""md""sm" |
smallStep0.4.0The small step value of the input element when incrementing while the alt key is held. | number |
snapOnStep0.4.0Whether the value should snap to the nearest step when incrementing or decrementing. | boolean |
step0.4.0Amount to increment and decrement with the buttons and arrow keys, or to scrub with pointer movement in the scrub area. | number | "any" |
value0.4.0The raw numeric value of the field. | number | null |
Além destas, a peça aceita className, style, id e children, repassados ao elemento de baixo.