npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

google-search-for-react

v0.1.0

Published

A simple search components it's UI just like google search

Downloads

10

Readme

google-search-for-react

English | 简体中文

A simple search components it's UI just like google search

Installation

npm i google-search-for-react --save

Usage

import React from 'react'
import Search from 'google-search-for-react'
class Demo extends React.PureComponent {

  mockData = value =>
    Array(18).fill({ name: `${value} :随机数${Math.random()}` });
  onSearchHistory = value =>
    new Promise(resolve => resolve(this.mockData(`${value}历史数据`)));
  onSearch = value => new Promise(resolve => resolve(this.mockData(value)));
  onEnter = value => {
    console.log("searchword:" + value);
  };
  placeholder = open =>
    open
      ? "指标搜索:最多支持三个关键词搜索,以空格隔开"
      : "指标搜索 (微贷/财富/保险)";
  renderContent = options => {
    const { rows, highlight, searchWords, handleClose } = options;
    return rows.map((item, index) => {
      const text = highlight(searchWords, item.name);
      return (
        <li
          key={`${index}content_li`}
          onClick={() => {
            console.log(item.name);
            handleClose();
          }}
        >
          <div dangerouslySetInnerHTML={{ __html: text }} />
        </li>
      );
    });
  };
  render() {
    return (
      <div>
        <div style={{ width: "90%" }}>
          <Search
            anchor="right"
            placeholder={this.placeholder}
            onSearchHistory={this.onSearchHistory} // 历史搜索
            onSearch={this.onSearch} // 搜索查询
            onEnter={this.onEnter} // 回车键入
            renderContent={this.renderContent} // 渲染内容
            renderFooter={this.renderFooter}
          />
        </div>
      </div>
    );
  }
}

API

| 成员 | 说明 | 类型 | 默认值 | |-------------|----------------|--------------------|--------------| | anchor | searchbar展开的方向 | String | 'right' | | placeholder | 必填,输入框底文 | String/Function:(isOpen)=>{} | | | onSearch | 搜索查询 | Function (searchWords)=> Promise | 无 | | onSearchHistory | 查询历史记录 | Function (searchWords)=> Promise| 无 | | onEnter | 搜索回车事件 | Function (searchWords)=>{} | 无 | | renderHeader | 自定义搜索结果面板的header | Function (rows)=>{} | 无 | | renderContent | 定义搜索结果面板的Content | Function ( {rows,highlight,searchWords,handleClose})=>{} | 无| | renderFooter | 定义搜索结果面板的Footer | Function (rows)=>{} | 无 |

Feature

  • Highlight Search:通过点击searchbar后,搜索框动态放大,占据视觉主体,从而突出搜索功能
  • Intelligence Related:智能联想,补全用户想要的内容
  • Recent Pages/Most Visted Pages:最近搜索的内容和热度最多的内容,帮助用户快速检索,增加用户粘性
  • One Search , All Products:同一体系下,搜索的交互和体验一致,提供后端接口服务
  • Search as a service:提供后端接口API,高效灵活,适配不同场景

reference

  • google search