New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

magical-search

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

magical-search

A React library for search fields and modals

latest
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

magical-search is a flexible and lightweight React library for rendering search modals and input fields. Ideal for integrating search functionality into your apps quickly and beautifully.

📦 Installation

npm install magical-search

or with pnpm:

pnpm add magical-search

🚀 Usage

import { SearchIcon } from 'magical-search';

type Person = {
  firstName: string;
  lastName: string;
  email: string;
};

const people: Person[] = [
  { firstName: 'Alice', lastName: 'Smith', email: 'alice@example.com' },
  { firstName: 'Bob', lastName: 'Jones', email: 'bob@example.com' },
];

<SearchIcon<Person>
  size={28}
  color="#1e90ff"
  data={people}
  searchKeys={['firstName', 'email']}
  renderItem={(person) => (
    <div>
      {person.firstName} {person.lastName}
      <br />
      <small>{person.email}</small>
    </div>
  )}
  onSelect={(person) => console.log('Selected:', person)}
/>

🔧 Props

PropTypeDescription
dataT[]The array of items to search
searchKeys(keyof T)[]Which fields to search in (e.g., ['name', 'email'])
renderItem(item: T) => React.ReactNodeCustom render function for each result item
onSelect(item: T) => voidCallback when an item is selected
sizenumberSize of the search icon (default: 24)
colorstringColor of the icon (e.g. #000, #1e90ff)
searchPlaceholderstringCustom placeholder text in the search input
emptyMessagestringCustom message if no search results are found
filter(item: T, query: string) => boolCustom filter logic (optional – overrides searchKeys)

🎥 Demo

Demo

✨ Features

  • 🔍 Full-text search in customizable object fields
  • 🎨 Fully stylable with SCSS modules
  • 💡 Autofocus when opening modal
  • 🔌 Extendable: supports filter, onSelect, placeholder, and more
  • 🧩 Designed for reuse across different data types

📜 License

MIT © Torben Gabriel

Keywords

react

FAQs

Package last updated on 10 Apr 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts