Skip to content

EtherInput Component

The EtherInput component provides an input for entering values in ETH or USD with a toggle to switch modes, automatic conversion based on the current native currency price, and a callback that reports both values.

Import

import { EtherInput } from "@scaffold-ui/components";

Props

PropTypeDefaultDescription
namestring-Name attribute for the input element
placeholderstring-Placeholder text for the input
defaultValuestring-Initial value for the input
defaultUsdModebooleanfalseStart with the input in USD mode instead of ETH
disabledbooleanfalseDisables the input and toggle button
onValueChange(value: { valueInEth: string; valueInUsd: string; displayUsdMode: boolean }) => void-Called when the value or display mode changes. Provides both ETH and USD values and current display mode
styleCSSProperties-Custom CSS styles (memoize to prevent re-renders)

Live Examples

Basic Usage

Ξ
import React from "react";
import { EtherInput } from "@scaffold-ui/components";
 
<EtherInput placeholder="Amount" />;

Default USD Mode

$
import React from "react";
import { EtherInput } from "@scaffold-ui/components";
 
<EtherInput
  defaultUsdMode
  placeholder="Enter amount in USD"
/>;

Default Value

Ξ
import React from "react";
import { EtherInput } from "@scaffold-ui/components";
 
<EtherInput defaultValue="0.5" />;

Disabled State

Ξ
import React from "react";
import { EtherInput } from "@scaffold-ui/components";
 
<EtherInput
  disabled
  placeholder="Disabled"
/>;

onValueChange Callback

Ξ
import React from "react";
import { EtherInput } from "@scaffold-ui/components";
 
<EtherInput
  placeholder="With onValueChange"
  onValueChange={({ valueInEth, valueInUsd, displayUsdMode }) => {
    console.log({ valueInEth, valueInUsd, displayUsdMode });
  }}
/>;