TokenList
A searchable list component for displaying and selecting tokens with optional balance information.
TokenList
The TokenList component provides a searchable list of tokens with support for balance display and token selection.
Usage
Props
| Prop | Type | Default | Description | 
|---|---|---|---|
| chain_id | number | - | Chain ID for the token list | 
| list | TokenItem[] | - | Array of tokens to display | 
| onClick | (address: string) => void | - | Callback when a token is selected | 
| selected | { address: string } | - | Currently selected token (optional) | 
| showBalances | boolean | false | Whether to show token balances | 
| className | string | - | Additional CSS classes | 
Features
- Search by token name, symbol, or contract address
- Displays token balances (optional)
- Highlights selected token
- Supports token whitelisting
- Responsive scrollable list
- Search input with clear functionality
Examples
Basic Token List
With Balances
With Selected Token
Token Item Structure
Each token in the list should follow this structure:
States
- Loading: Shows loading state when fetching balances
- Empty Search: Displays all tokens in the list
- Search Results: Shows filtered tokens based on search input
- Selected: Highlights the currently selected token
- Non-whitelisted: Shows warning for non-whitelisted tokens
Search Functionality
The component supports searching by:
- Token name
- Token symbol
- Exact contract address
When searching by contract address:
- Must be a valid Ethereum address
- Shows token details if found in the list
- Can show import option for non-whitelisted tokens
Is this guide helpful?