{"id":29733130,"url":"https://github.com/chrisg86/react-wrap-text","last_synced_at":"2026-01-20T16:50:48.714Z","repository":{"id":305939201,"uuid":"1024429585","full_name":"chrisg86/react-wrap-text","owner":"chrisg86","description":"A simple utility to wrap matching substrings in React with custom jsx components","archived":false,"fork":false,"pushed_at":"2025-07-22T19:12:21.000Z","size":31,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-22T20:21:27.996Z","etag":null,"topics":["highlight","jsx","react","react-utils","text-highlighter","text-replace"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chrisg86.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-22T17:24:56.000Z","updated_at":"2025-07-22T19:11:45.000Z","dependencies_parsed_at":"2025-07-22T20:22:12.180Z","dependency_job_id":"6b4be918-a357-4d43-8556-a89bbf1eeeaa","html_url":"https://github.com/chrisg86/react-wrap-text","commit_stats":null,"previous_names":["chrisg86/react-wrap-text"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/chrisg86/react-wrap-text","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisg86%2Freact-wrap-text","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisg86%2Freact-wrap-text/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisg86%2Freact-wrap-text/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisg86%2Freact-wrap-text/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chrisg86","download_url":"https://codeload.github.com/chrisg86/react-wrap-text/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisg86%2Freact-wrap-text/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266989984,"owners_count":24017713,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-25T02:00:09.625Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["highlight","jsx","react","react-utils","text-highlighter","text-replace"],"created_at":"2025-07-25T09:47:26.379Z","updated_at":"2025-10-03T12:02:31.112Z","avatar_url":"https://github.com/chrisg86.png","language":"TypeScript","readme":"# ✨ react-wrap-text\nA tiny utility for highlighting or replacing specific text matches inside strings with custom React components.\n\nPerfect for inline highlighting, smart mentions, tokenized UI, or simple templating in JSX.\n\n## 🚀 Install\n```\nnpm install react-wrap-text\n```\n\n## Usage\n\n### Example 1: Highlight\nUse `wrapMatchesInText` if you want to highlight specific parts of the text.\n\n```ts\nimport { wrapMatchesInText } from 'react-wrap-matches';\n\n// Define an optional wrapper component\nconst Highlight = ({ children }: { children: React.ReactNode }) =\u003e (\n  \u003cmark\u003e{children}\u003c/mark\u003e\n);\n\nconst text = \"Hit or miss, I guess they never miss, huh?\";\n\nconst result = wrapMatchesInText(text, \"miss\", (match, i) =\u003e (\n  \u003cHighlight key={i}\u003e{match}\u003c/Highlight\u003e\n));\n\n// Output: \n// Hit or \u003cmark\u003emiss\u003c/mark\u003e, I guess they never \u003cmark\u003emiss\u003c/mark\u003e, huh?\nreturn \u003cp\u003e{result}\u003c/p\u003e;\n```\n\n\n### Example 2: Replace\nUse `wrapMatchesInText` if you want to replace matching parts of the text with a JSX component.\n\n```ts\nimport { wrapMatchesInText } from 'react-wrap-matches';\n\nconst text = \"You've scored 100 points!\";\n\nconst result = wrapMatchesInText(text, \"100\", (_, i) =\u003e (\n  // This also works with inline jsx\n  \u003cstrong key={i}\u003e💯\u003c/strong\u003e\n));\n\n// Output\n// You've scored \u003cstrong\u003e💯\u003c/strong\u003e points!\nreturn \u003cp\u003e{result}\u003c/p\u003e;\n```\n\n\n### Example 3: Advanced - Highlight multiple\nUse `wrapMultipleMatchesInText` if you need to highlight/replace multiple substrings.\n\n```ts\nimport { wrapMultipleMatchesInText } from 'react-wrap-matches';\n\nconst Highlight = ({ children }: { children: React.ReactNode }) =\u003e (\n\t\u003cmark\u003e{children}\u003c/mark\u003e\n);\n\nconst HighlightOrange = ({ children }: { children: React.ReactNode }) =\u003e (\n\t\u003cmark style={{ backgroundColor: \"oklch(75% 0.183 55.934)\" }}\u003e{children}\u003c/mark\u003e\n);\n\nconst text = \"This is a test. This test works.\";\n\nconst multiPayload: Parameters\u003ctypeof wrapMultipleMatchesInText\u003e[1] = [\n\t{\n\t\ttarget: \"This\",\n\t\trender: (match, i) =\u003e \u003cHighlight key={i}\u003e{match}\u003c/Highlight\u003e,\n\t},\n\t{\n\t\ttarget: \"works\",\n\t\trender: (match, i) =\u003e \u003cHighlightOrange key={i}\u003e{match}\u003c/HighlightOrange\u003e,\n\t}\n];\n\nconst result = wrapMultipleMatchesInText(text, multiPayload);\n\n// Output\n// \u003cmark\u003eThis\u003c/mark\u003e is a test. \u003cmark\u003eThis\u003c/mark\u003e test \u003cmark style=\"background-color: oklch(0.75 0.183 55.934);\"\u003eworks\u003c/mark\u003e.\nreturn \u003cp\u003e{result}\u003c/p\u003e;\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrisg86%2Freact-wrap-text","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchrisg86%2Freact-wrap-text","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrisg86%2Freact-wrap-text/lists"}