Trading
Instrument Search
Virtualized search box for picking an account instrument across exchanges. Supports multi-word matching against account, exchange, market, and pair, plus full keyboard navigation.
Preview
Source
Copy this file to components/trading/instrument-search.tsx
tsx
'use client'
import * as React from 'react'
import { useState, useMemo, useEffect, useRef } from 'react'
import { useVirtualizer } from '@tanstack/react-virtual'
import { Search, X } from 'lucide-react'
import { cn } from '@/lib/utils'
export interface Instrument {
account: string
exchange: string
market: string
pair: string
}
export interface InstrumentSearchProps {
value?: Instrument | null
onChange: (instrument: Instrument | null) => void
instruments: Instrument[]
placeholder?: string
className?: string
}
// Virtualized instrument search with multi-word matching (each word must match
// any of account/exchange/market/pair) and keyboard navigation. Shows each
// instrument as labeled Account/Exchange/Market/Pair lines with a results footer.
// See components/trading/instrument-search.tsx for the full implementation.Props
| Prop | Type |
|---|---|
| instruments* | Instrument[] |
| onChange* | (instrument: Instrument | null) => void |
| value | Instrument | null |
| placeholder | string |
| className | string |