Ir al contenido

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
  1. Dos monedas
  2. Cuándo usarlo
  3. Para todos
  4. Props

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 currency ISO 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

CurrencyInputTipoPor defecto
currencyobligatorio string
aria-describedby string
aria-label

The name for screen readers when there is no Field around it.

string
aria-labelledby string
className string
defaultValue number
disabled boolean
id

Inside a Field it comes from the Field.

string
invalid

Marks 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"
step

How much each press of a stepper or an arrow key adds.

number
value

The number, or null while the box is empty.

number | null
FieldTipoPor defecto
labelobligatorio ReactNode
className string
error

What is wrong and how to fix it. Its presence marks the control as invalid.

ReactNode
hint

Help that is always visible: what to write, in what format.

ReactNode
optional

Adds «optional» beside the label. Required is the default and is not marked.

boolean
wide

Spans both columns of a FormGrid.

boolean
  1. Dos monedas
  2. Cuándo usarlo
  3. Para todos
  4. Props

    Busca páginas, secciones y términos