Components
Address Input
Recipient field that takes an address or ENS name, resolves names, and catches checksum typos.
Type or paste an address or an ENS name. Names resolve on mainnet once typing pauses, with the avatar and resolved address shown. Mixed-case addresses must match their checksum, which catches most single-character typos. Problems show after the field loses focus, not while typing.
Try vitalik.eth, a pasted address, or flip the case of one letter.
Installation
Section titled “Installation”npx shadcn@latest add @0xui/address-inputpnpm dlx shadcn@latest add @0xui/address-inputyarn dlx shadcn@latest add @0xui/address-inputbunx --bun shadcn@latest add @0xui/address-inputimport { AddressInput } from "@/components/address-input";
const [text, setText] = useState("");const [recipient, setRecipient] = useState<Address>();
<AddressInput value={text} onValueChange={setText} onResolve={(state) => setRecipient(state.address)}/>;Always send to state.address, never to the raw text. It is undefined until the input is a valid address or a resolved name.
Private addresses
Section titled “Private addresses”With shielded, the field also accepts a private 0zk… address, for a recipient inside a private balance. It is checked by length and by its own checksum, so one wrong character is caught. The result is in state.shieldedAddress, and state.address stays undefined.
Paste a 0zk address, then change one character.
<AddressInput value={text} onValueChange={setText} shielded onResolve={(state) => setRecipient(state.shieldedAddress ?? state.address)}/>A private address is never sent to an ENS resolver or any other lookup. Without shielded, a pasted 0zk address is turned down with “Private (0zk) addresses can’t be used here.”
The format is Railgun’s: 0zk, 127 characters, bech32m. isShieldedAddress in lib/0xui-utils is the same check on its own.
States
Section titled “States”data-phase on the root holds the current state.
| Phase | Meaning |
|---|---|
empty |
Nothing typed. |
incomplete |
Not a full address or name yet. Reported after blur. |
resolving |
Looking up an ENS name. |
valid |
state.address is set. For names, the resolved address is shown under the field. For addresses, the ENS name is shown. |
invalid |
Bad checksum, too long, or not a valid name. Reported after blur. |
not-found |
The name has no address. Reported right away. |
Also accepts <input> props.
| Prop | Type | Default | Description |
|---|---|---|---|
value |
string |
— | Text in the field. |
onValueChange |
(value) => void |
— | Called on every change. |
onResolve |
(state) => void |
— | Called when validation settles on a new result. |
label |
string |
"Recipient" |
Accessible label. |
showPaste |
boolean |
true |
Paste button while empty. |
shielded |
boolean |
false |
Also accept private 0zk… addresses. |
Headless: useAddressInput(value, { shielded }) returns the same state.
