{"id":35434612,"url":"https://github.com/stevenvachon/react-splitting","last_synced_at":"2026-01-20T17:38:24.469Z","repository":{"id":324626670,"uuid":"1097715828","full_name":"stevenvachon/react-splitting","owner":"stevenvachon","description":"A re-implementation of splitting.js for React supporting SSR/SSG.","archived":false,"fork":false,"pushed_at":"2025-12-26T18:37:01.000Z","size":21,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-12-28T04:55:05.296Z","etag":null,"topics":["animation","react","splitting","text"],"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/stevenvachon.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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-11-16T17:43:20.000Z","updated_at":"2025-12-26T18:37:05.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/stevenvachon/react-splitting","commit_stats":null,"previous_names":["stevenvachon/react-splitting"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/stevenvachon/react-splitting","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stevenvachon%2Freact-splitting","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stevenvachon%2Freact-splitting/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stevenvachon%2Freact-splitting/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stevenvachon%2Freact-splitting/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stevenvachon","download_url":"https://codeload.github.com/stevenvachon/react-splitting/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stevenvachon%2Freact-splitting/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28179571,"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":"2026-01-02T02:00:06.235Z","response_time":54,"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":["animation","react","splitting","text"],"created_at":"2026-01-02T22:03:32.770Z","updated_at":"2026-01-20T17:38:24.463Z","avatar_url":"https://github.com/stevenvachon.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-splitting [![NPM Version][npm-image]][npm-url] ![Build Status][ghactions-image] [![Coverage Status][codecov-image]][codecov-url]\n\n\u003e An (incomplete) re-implementation of [splitting.js](https://npmjs.com/splitting) for React supporting SSR/SSG.\n\nThis is a _re_-implementation because the original works with _real_ DOM nodes. Converting `ReactNode`s to such then back again _might_ preserve most--if not all--attributes, but will definitely _lose all_ React event handlers.\n\n\u003e [!WARNING]\n\u003e\n\u003e - Only \"chars\" and \"words\" are supported for the `by` property.\n\u003e - `\u003cscript\u003e` and `\u003cstyle\u003e` elements are [property ignored](https://github.com/shshaw/Splitting/issues/111).\n\u003e - The `key` option was renamed to `cssKey` to avoid a conflict with React's own [`key` property](https://react.dev/learn/rendering-lists#keeping-list-items-in-order-with-key).\n\u003e   - It is [properly prefixed](https://github.com/shshaw/Splitting/issues/110).\n\n\u003e [!NOTE]\n\u003e\n\u003e - This library comes in two variants: one with \"meta\" and one without. **The \"meta\" variant is a drop-in replacement** for the original library as it replicates its CSS classes, CSS variables, `data-*` attributes and some quirky whitespace handling.\n\u003e - Each variant can be used as a **component**--which offers nothing additional--or as a **function**--which adds counts for characters \u0026 words and **access to data before it's rendered**.\n\n## Consumer Usage\n\n### Installation\n\n```shell\nnpm install react-splitting\n```\n\n### `\u003cSplitting /\u003e` / `splitting()`\n\nLightweight and completely customizable.\n\n```tsx\nimport { CHARS, Splitting, WORDS } from 'react-splitting';\n\nexport default () =\u003e (\n  \u003c\u003e\n    \u003cp\u003e\n      \u003cSplitting by={WORDS}\u003e\n        Text \u003cstrong\u003esplit\u003c/strong\u003e by \u003cem\u003ewords\u003c/em\u003e.\n      \u003c/Splitting\u003e\n    \u003c/p\u003e\n    \u003cp\u003e\n      \u003cSplitting by={CHARS}\u003e\n        Text \u003cstrong\u003esplit\u003c/strong\u003e by \u003cem\u003echaracters\u003c/em\u003e.\n      \u003c/Splitting\u003e\n    \u003c/p\u003e\n    With more customization:\n    \u003cp\u003e\n      \u003cSplitting by={WORDS} wordProps={i =\u003e ({ className: 'word', style: { '--word-index': i } })}\u003e\n        Text \u003cstrong\u003esplit\u003c/strong\u003e by \u003cem\u003ewords\u003c/em\u003e.\n      \u003c/Splitting\u003e\n    \u003c/p\u003e\n    \u003cp\u003e\n      \u003cSplitting\n        by={CHARS}\n        charProps={i =\u003e ({ className: 'char', style: { '--char-index': i } })}\n        wordProps={i =\u003e ({ className: 'word', style: { '--word-index': i } })}\n      \u003e\n        Text \u003cstrong\u003esplit\u003c/strong\u003e by \u003cem\u003echaracters\u003c/em\u003e.\n      \u003c/Splitting\u003e\n    \u003c/p\u003e\n  \u003c/\u003e\n);\n```\n\n```tsx\nimport { splitting, WORDS } from 'react-splitting';\n\nexport default () =\u003e {\n  const { charCount, result, wordCount } = splitting(\n    \u003c\u003e\n      Text \u003cstrong\u003esplit\u003c/strong\u003e by \u003cem\u003ewords\u003c/em\u003e.\n    \u003c/\u003e,\n    {\n      by: WORDS,\n      charProps: i =\u003e ({ className: 'char', style: { '--char-index': i } }),\n      wordProps: i =\u003e ({ className: 'word', style: { '--word-index': i } }),\n    }\n  );\n  return \u003cp\u003e{result}\u003c/p\u003e;\n};\n```\n\n### `\u003cSplittingWithMeta /\u003e` / `splittingWithMeta()`\n\nDrop-in replacement.\n\n```tsx\nimport { SplittingWithMeta } from 'react-splitting/with-meta';\n\nexport default () =\u003e (\n  \u003cSplittingWithMeta as=\"div\"\u003e\n    Text with \u003cstrong\u003eadded metadata\u003c/strong\u003e, split by \u003cem\u003echaracters\u003c/em\u003e.\n  \u003c/SplittingWithMeta\u003e\n);\n```\n\n```tsx\nimport { splittingWithMeta, WORDS } from 'react-splitting/with-meta';\n\nexport default () =\u003e {\n  const { charCount, result, wordCount } = splittingWithMeta(\n    \u003c\u003e\n      Text \u003cstrong\u003esplit\u003c/strong\u003e by \u003cem\u003ewords\u003c/em\u003e.\n    \u003c/\u003e,\n    { as: 'div', by: WORDS }\n  );\n  return result;\n};\n```\n\n## Development Usage\n\n### Production Build\n\n```shell\nnpm run build\n```\n\n### Testing\n\nThe test suite can perform a _single run_:\n\n```shell\nnpm test\n```\n\n… or indefinitely as files are changed:\n\n```shell\nnpm run test:watch\n```\n\n## To Do\n\n- Simplify types by using \"segment\" instead of \"char\" or \"word\".\n- Test with languages that don't use normal whitespace delimiters, if any such exist. Check out [grapheme-splitter](https://npmjs.com/grapheme-splitter).\n- Probably add ESLint.\n- Remove [tsc-alias](https://npmjs.com/tsc-alias) and use `rewriteRelativeImportExtensions` with `allowImportingTsExtensions` [when possible](https://github.com/microsoft/TypeScript/issues/61037).\n- Try using [happy-dom](https://npmjs.com/happy-dom) again. It [didn't support splitting.js](https://github.com/capricorn86/happy-dom/issues/1959).\n\n[npm-image]: https://img.shields.io/npm/v/react-splitting\n[npm-url]: https://npmjs.org/react-splitting\n[ghactions-image]: https://img.shields.io/github/actions/workflow/status/stevenvachon/react-splitting/test.yml\n[codecov-image]: https://img.shields.io/codecov/c/github/stevenvachon/react-splitting\n[codecov-url]: https://app.codecov.io/github/stevenvachon/react-splitting\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstevenvachon%2Freact-splitting","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstevenvachon%2Freact-splitting","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstevenvachon%2Freact-splitting/lists"}