Search component provides a full-screen modal interface for searching tracks, artists, albums, and playlists with keyboard shortcuts and filtered results.
Features
- Keyboard Shortcuts - Open with Cmd/Ctrl+K, close with Escape
- Debounced Search - 300ms debounce to reduce API calls
- Filtered Results - Filter by All, Artists, Albums, Songs, or Playlists
- Quick Actions - Add tracks to queue with a single click
- Toast Notifications - Visual feedback when adding to queue
- Responsive UI - Full-screen modal with backdrop
Component API
Search
No props required - UsesSpotifyContext internally for SDK access
Usage
Basic Implementation
With Spotify Context
Keyboard Shortcuts
- Cmd/Ctrl + K - Open search modal
- Escape - Close search modal and reset filters
Search Filters
The component provides these filter options:| Filter | Value | Description |
|---|---|---|
| All | all | Search across all content types |
| Artists | artist | Search only for artists |
| Albums | album | Search only for albums |
| Songs | track | Search only for tracks |
| Playlists | playlist | Search only for playlists |
Result Types
Track Result
Artist Result
Album Result
Playlist Result
Actions
Add to Queue
Clicking a track result adds it to the Spotify playback queue:Styling
The component uses dynamic CSS variables for theming:Loading States
Debouncing
The component uses a customuseDebounce hook:
Toast Notifications
Uses Sonner for toast notifications when adding tracks:Implementation Details
The component at/home/daytona/workspace/source/src/components/Search.tsx:33 uses React.memo for performance and manages modal state internally.