CurrencyInput
Una cantidad de dinero en una moneda, escrita como la escribe el idioma de la persona. El valor es un número.
import { CurrencyInput, Field } from '@sypnia/ui/react'
En esta página
Dos monedas
Saved as 29
Saved as 120000
Código
import { useState } from 'react';
import { CurrencyInput, Field, FormGrid } from '@sypnia/ui/react';
// The amount is a number; it is written the way the person's language writes money in that currency.
export default function Price() {
const [usd, setUsd] = useState<number | null>(29);
const [cop, setCop] = useState<number | null>(120000);
return (
<FormGrid>
<Field label="Monthly price" hint={`Saved as ${usd ?? '—'}`}><CurrencyInput currency="USD" value={usd} onChange={setUsd} /></Field>
<Field label="Price in Colombia" hint={`Saved as ${cop ?? '—'}`}><CurrencyInput currency="COP" value={cop} onChange={setCop} /></Field>
</FormGrid>
);
} Cuándo usarlo
Úsalo cuando
- Precios, límites y montos para cobrar.
- Pasa la
currencyISO de la cuenta: «USD», «COP».
No lo uses cuando
- Montos en varias monedas a la vez: un campo por moneda.
Para todos
- Es un campo numérico: las flechas suben y bajan, y la moneda se lee con el valor.
Props
| CurrencyInput | Tipo | Por defecto |
|---|---|---|
currencyobligatorio | string | |
aria-describedby | string | |
aria-labelThe name for screen readers when there is no Field around it. | string | |
aria-labelledby | string | |
className | string | |
defaultValue | number | |
disabled | boolean | |
idInside a Field it comes from the Field. | string | |
invalidMarks the value as wrong. Inside a `<Field error>` it is set for you. | boolean | |
max | number | |
min | number | |
name | string | |
onChange | ((value: number | null) => void) | |
placeholder | string | |
size | "sm" | "md" | "lg" | |
stepHow much each press of a stepper or an arrow key adds. | number | |
valueThe number, or null while the box is empty. | number | null |
| Field | Tipo | Por defecto |
|---|---|---|
labelobligatorio | ReactNode | |
className | string | |
errorWhat is wrong and how to fix it. Its presence marks the control as invalid. | ReactNode | |
hintHelp that is always visible: what to write, in what format. | ReactNode | |
optionalAdds «optional» beside the label. Required is the default and is not marked. | boolean | |
wideSpans both columns of a FormGrid. | boolean |