Love This UI? Help It Grow and Reach More Developers Worldwide

Search Component

A beautiful and interactive search component with gradient borders, keyboard shortcuts, and recent search functionality. Perfect for command palettes, global search interfaces, and application navigation.

Features

  • Keyboard Shortcuts: Built-in Ctrl+K (Cmd+K on Mac) support for quick access
  • Recent Searches: Displays and manages recent search history with clear functionality
  • Gradient Border: Eye-catching gradient border with glow effects
  • Dark Mode: Full support for light and dark themes
  • Responsive Design: Adapts to different screen sizes and layouts
  • Real-time Filtering: Instant search results as you type
  • Accessible: Proper focus management and keyboard navigation
  • Customizable Icons: Includes custom SVG icons for popular services

Basic Example

K

Recent search

  • Slack
    4 Messages
  • Binance
    8 Updates
  • Dribble
    2 Updates
  • Figma
    12 Comments

Usage

After installing the component, you can use it in your React application:

Loading...

Keyboard Shortcuts

The search component includes built-in keyboard shortcuts for enhanced user experience:

| Shortcut | Action | |----------|--------| | Ctrl+K / Cmd+K | Focus the search input | | Escape | Clear search input (when focused) | | Enter | Select highlighted search result |

Customization

Search Data Structure

The component uses a predefined data structure for search items:

Loading...

Custom Search Items

You can customize the search items by modifying the recentSearches array:

Loading...

Installation

npx shadcn@latest add search.json

Dependencies

This component requires the following dependencies:

Loading...

Component Props

PropTypeDefaultRequiredDescription
classNamestringundefinedNoAdditional CSS classes to apply to the search container
placeholderstringSearch the app..NoPlaceholder text for the search input
onSearch(term: string) => voidundefinedNoCallback function called when search term changes
onItemSelect(item: SearchItemType) => voidundefinedNoCallback function called when a search item is selected

Styling

The component uses Tailwind CSS classes and includes:

  • Gradient borders with purple, orange, and pink colors
  • Backdrop blur effects for a modern glass-morphism look
  • Hover animations with scale transforms
  • Shadow effects that respond to theme changes
  • Responsive spacing that adapts to screen sizes

Browser Support

  • ✅ Chrome (latest)
  • ✅ Firefox (latest)
  • ✅ Safari (latest)
  • ✅ Edge (latest)

Accessibility

The search component follows accessibility best practices:

  • Keyboard Navigation: Full keyboard support with proper focus management
  • ARIA Labels: Appropriate ARIA attributes for screen readers
  • Focus Indicators: Clear visual focus indicators
  • Semantic HTML: Uses proper HTML elements for better accessibility