Skip to main content

AmountInput

AmountInput is a React component that provides input functionality for SUI token amounts with validation and error handling.

Usage

import { AmountInput } from '@suiware/kit';

function MyComponent() {
const [amount, setAmount] = useState('');

return (
<AmountInput
value={amount}
onChange={setAmount}
/>
);
}

Props

PropTypeDescriptionDefault
valuestringThe input valueRequired
onChange(value: string) => voidCallback function when value changesRequired
placeholderstringInput placeholder text'Enter SUI amount'
classNamestringAdditional CSS class names''
disabledbooleanWhether the input is disabledfalse

Features

  • Validates numeric input values

  • Allows decimal points for fractional amounts

  • Prevents negative values

  • Real-time validation with error state display

  • Customizable styling via className prop

  • Controlled component with value/onChange pattern

Validation Rules

The component validates input according to these rules:

  • Only numbers and a single decimal point are allowed

  • No negative values

  • Empty input is considered valid

  • Non-numeric characters are rejected

Invalid inputs display an error message

Example with Custom Styling

import { AmountInput } from '@suiware/kit';

function MyComponent() {
const [amount, setAmount] = useState('');

return (
<AmountInput
value={amount}
onChange={setAmount}
className="custom-input"
placeholder="Enter amount in SUI"
/>
);
}