Ir al contenido

PercentInput

Una parte escrita como porcentaje. El valor es una fracción: 25 % es 0,25.

import { PercentInput } from '@sypnia/ui/react'

En esta página
  1. Un descuento
  2. Cuándo usarlo
  3. Para todos
  4. Props

Un descuento

Saved as 0.15

Código
import { useState } from 'react';
import { Field, PercentInput } from '@sypnia/ui/react';

// Typed as a percent, saved as a fraction: 25 % is 0.25.
export default function Discount() {
  const [v, setV] = useState<number | null>(0.15);
  return <Field label="Discount for yearly plans" hint={`Saved as ${v ?? '—'}`}><PercentInput value={v} onChange={setV} /></Field>;
}

Cuándo usarlo

Úsalo cuando

  • Descuentos, umbrales, tasas de muestreo.

No lo uses cuando

  • Números enteros de cosas: usa NumberInput.

Para todos

  • El signo de porcentaje se lee con el valor.

Props

PercentInputTipoPor defecto
aria-describedby string
aria-label

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

string
aria-labelledby string
className string
decimals number
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
  1. Un descuento
  2. Cuándo usarlo
  3. Para todos
  4. Props

    Busca páginas, secciones y términos