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

@cp949/react-highlight-words

v0.1.0

Published

React component and headless utilities for highlighting query matches inside text.

Readme

@cp949/react-highlight-words

텍스트 안의 검색어 매칭 구간을 강조하는 React 컴포넌트와 헤드리스 유틸리티입니다.

설치

pnpm add @cp949/react-highlight-words
npm i @cp949/react-highlight-words

사용법

import { Highlighter } from "@cp949/react-highlight-words";

export function Demo() {
  return (
    <Highlighter
      text="The dog is chasing the cat."
      query={["dog", "cat"]}
      autoEscape
      wholeWord
      highlight={{ as: "mark", className: "highlight" }}
      active={{ index: 0, className: "active" }}
    />
  );
}

헤드리스 사용법

import { useHighlightChunks } from "@cp949/react-highlight-words";

function CustomHighlight({ text, query }: { text: string; query: string }) {
  const chunks = useHighlightChunks({ text, query, autoEscape: true });

  return chunks.map((chunk) => (
    <span key={`${chunk.start}-${chunk.end}`} data-highlight={chunk.highlight}>
      {text.substring(chunk.start, chunk.end)}
    </span>
  ));
}

Props

| Prop | Type | 필수 | 설명 | | --- | --- | :---: | --- | | text | string | ✓ | 강조 대상 원본 텍스트 | | query | string \| RegExp \| ReadonlyArray<string \| RegExp> | ✓ | 검색어. 문자열 query 는 trim 후 빈 값이면 무시 | | autoEscape | boolean | | 문자열 query 의 정규식 메타문자 이스케이프 | | caseSensitive | boolean | | 대소문자 구분 검색 여부. 기본 false | | wholeWord | boolean | | 유니코드 단어 경계 기준으로 전체 단어만 매칭 | | sanitize | (text: string) => string | | 비교 전 전처리. 원본과 다른 길이를 반환하면 에러 발생 | | findChunks | (options: FindChunksOptions) => FindChunk[] | | 사용자 정의 매칭 함수 | | active | { index: number; className?: string; style?: CSSProperties } | | 특정 강조 매치 활성화 | | highlight | { as?; className?; style?; classNameByMatch? } | | 강조 슬롯 설정 | | unhighlight | { as?; className?; style? } | | 비강조 슬롯 설정 | | renderHighlight | (args: RenderHighlightArgs) => ReactNode | | 강조 구간 완전 커스텀 렌더링 | | renderUnhighlight | (args: RenderUnhighlightArgs) => ReactNode | | 비강조 구간 완전 커스텀 렌더링 | | as | ElementType | | 외곽 wrapper. 기본 "span" | | className | string | | 외곽 wrapper className |

코어 함수

import {
  combineChunks,
  fillInChunks,
  findAll,
  findChunks,
} from "@cp949/react-highlight-words";

라이선스

MIT