Skip to main content

EtherInput

A component that allows users to input an amount of ETH with real-time ETH/USD conversion and balance validation.

EtherInput Example

Import

import { EtherInput } from "~~/components/eth-mobile";

Usage

const [ethAmount, setEthAmount] = useState("");
const userBalance = useBalance(); // Your balance hook

<EtherInput
value={ethAmount}
onChange={setEthAmount}
onSubmit={() => console.log("Submitted:", ethAmount)}
balance={userBalance}
/>;

Props

PropTypeDefault ValueRequiredDescription
valuestringundefinedYesThe current input value (ETH amount or USD amount based on currency mode).
onChange(value: string) => voidundefinedYesCallback invoked when the input value changes.
onSubmit() => voidundefinedYesCallback function invoked when the user submits the input value.
balancebigint | nullundefinedNoThe user's ETH balance for validation (optional).
disabledbooleanfalseNoWhether the input is disabled.