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
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
| PercentInput | Tipo | Por defecto |
|---|---|---|
aria-describedby | string | |
aria-labelThe name for screen readers when there is no Field around it. | string | |
aria-labelledby | string | |
className | string | |
decimals | number | |
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 |