{"id":21009007,"url":"https://github.com/avin/react-substring","last_synced_at":"2026-03-06T09:32:04.279Z","repository":{"id":57345894,"uuid":"155908024","full_name":"avin/react-substring","owner":"avin","description":"Replace substrings with components","archived":false,"fork":false,"pushed_at":"2018-12-22T20:30:27.000Z","size":1429,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-07T07:04:54.496Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://avin.github.io/react-substring","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/avin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-11-02T18:41:50.000Z","updated_at":"2020-03-12T21:24:33.000Z","dependencies_parsed_at":"2022-09-17T22:13:27.729Z","dependency_job_id":null,"html_url":"https://github.com/avin/react-substring","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avin%2Freact-substring","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avin%2Freact-substring/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avin%2Freact-substring/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avin%2Freact-substring/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/avin","download_url":"https://codeload.github.com/avin/react-substring/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225324104,"owners_count":17456460,"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","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":[],"created_at":"2024-11-19T09:15:10.327Z","updated_at":"2025-10-10T08:36:29.008Z","avatar_url":"https://github.com/avin.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-substring\n\n\u003e Decorating substrings with components. Useful to highlight something in your text content.\n\n[![NPM registry](https://img.shields.io/npm/v/react-substring.svg?style=for-the-badge)](https://yarnpkg.com/en/package/react-substring)\n![](https://img.shields.io/travis/:avin/:react-substring.svg?style=for-the-badge) \n[![NPM license](https://img.shields.io/badge/license-mit-red.svg?style=for-the-badge)](LICENSE)\n\n## Demo\n\nHere is an [examples page](https://avin.github.io/react-substring)\n\n## Install\n\n```bash\n# Yarn\nyarn add react-substring\n\n# NPM\nnpm install --save react-substring\n```\n\n## Features\n\n* Search substrings by simple string or regular expressions.\n* Decorate substrings with custom components or just add some style or className to them.\n* Personal decorating for each match pattern.\n\n## Usage\n\n```js\nimport React from 'react';\nimport Substring from 'react-substring';\n\nconst RedString = ({ children }) =\u003e \u003cspan style={{ color: 'red' }}\u003e{children}\u003c/span\u003e;\n\nconst DemoComponent = () =\u003e (\n    \u003cSubstring\n        substrings={[\n            {\n                match: new RegExp('Decorate', 'gi'),\n                component: 'b',\n            },\n            {\n                match: 'custom',\n                caseSensitive: true,\n                component: RedString,\n            },\n            {\n                match: ['just', 'some', /className/gi],\n                props: { style: { backgroundColor: 'red' } },\n            },\n        ]}\n    \u003e\n        Decorate substrings with custom components or just add some style or className to them\n    \u003c/Substring\u003e\n);\n```\n\n## API\n\n#### Props\n\n| Property     | Type             | Required? | Description                                                                                        |\n| :----------- | :--------------- | :-------: | :------------------------------------------------------------------------------------------------- |\n| substrings   | Array\u003cSubstring\u003e |     ✓     | Array on Substring objects.                                                                        |\n| outerTagName | String           |           | Tag name passed to document.createElement to create the outer container element. (Default: `span`) |\n| style        | Object           |           | Optional inline style to attach to outermost element.                                              |\n| className    | Object           |           | Optional inline style to attach to outermost element.                                              |\n\n#### Substring object fields\n\n| Field name    | Type                      | Required? | Description                                                                                        |\n| :------------ | :------------------------ | :-------: | :------------------------------------------------------------------------------------------------- |\n| match         | RegExp or String          |     ✓     | Pattern to search substrings for processing. Can use array of patterns here.                       |\n| component     | React.Component or String |           | React component or tag name taking matching content. (Default: `mark`)                             |\n| caseSensitive | Bool                      |           | If use match as string - it allows to switch on case sensitive search substring (Default: `false`) |\n| props         | Object                    |           | Additional props for matching component (can use `style`, `className` or something else)           |\n\n## License\n\nMIT © [avin](https://github.com/avin)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favin%2Freact-substring","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Favin%2Freact-substring","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favin%2Freact-substring/lists"}