{"id":28097112,"url":"https://github.com/jamieweavis/string-to-tailwind-color","last_synced_at":"2026-02-17T22:03:06.543Z","repository":{"id":287536323,"uuid":"964685359","full_name":"jamieweavis/string-to-tailwind-color","owner":"jamieweavis","description":"Generates a random but deterministic Tailwind CSS color and shade from a string","archived":false,"fork":false,"pushed_at":"2025-10-17T15:58:48.000Z","size":365,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-18T18:21:10.131Z","etag":null,"topics":["color","deterministic","hash","shade","string-hashing","string-to-color","tailwindcss"],"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/jamieweavis.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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-04-11T16:05:42.000Z","updated_at":"2025-10-17T15:58:51.000Z","dependencies_parsed_at":null,"dependency_job_id":"7c08ac6f-06ed-4360-befa-0b12a3ca2b07","html_url":"https://github.com/jamieweavis/string-to-tailwind-color","commit_stats":null,"previous_names":["jamieweavis/string-to-tailwind-color"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/jamieweavis/string-to-tailwind-color","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamieweavis%2Fstring-to-tailwind-color","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamieweavis%2Fstring-to-tailwind-color/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamieweavis%2Fstring-to-tailwind-color/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamieweavis%2Fstring-to-tailwind-color/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jamieweavis","download_url":"https://codeload.github.com/jamieweavis/string-to-tailwind-color/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamieweavis%2Fstring-to-tailwind-color/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29559961,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-17T21:50:49.831Z","status":"ssl_error","status_checked_at":"2026-02-17T21:46:15.313Z","response_time":100,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["color","deterministic","hash","shade","string-hashing","string-to-color","tailwindcss"],"created_at":"2025-05-13T16:59:16.281Z","updated_at":"2026-02-17T22:03:06.538Z","avatar_url":"https://github.com/jamieweavis.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# String to Tailwind Color\n\nGenerates a random but deterministic Tailwind CSS color and shade from a string\n\n[![ci](https://github.com/jamieweavis/string-to-tailwind-color/workflows/ci/badge.svg)](https://github.com/jamieweavis/string-to-tailwind-color/actions)\n[![dependencies](https://img.shields.io/badge/dependencies-0-green)](https://npmjs.com/package/string-to-tailwind-color)\n[![coverage](https://img.shields.io/badge/coverage-100%25-green)](https://npmjs.com/package/string-to-tailwind-color)\n[![downloads](https://img.shields.io/npm/dt/string-to-tailwind-color.svg)](https://npmjs.com/package/string-to-tailwind-color)\n[![version](https://img.shields.io/npm/v/string-to-tailwind-color.svg)](https://github.com/jamieweavis/string-to-tailwind-color/releases)\n[![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/jamieweavis/string-to-tailwind-color/blob/main/LICENSE)\n\n## Install\n\nInstall from npm with your favourite package manager:\n\n```sh\n# npm\nnpm install string-to-tailwind-color\n\n# yarn\nyarn add string-to-tailwind-color\n\n# pnpm\npnpm add string-to-tailwind-color\n\n# bun\nbun add string-to-tailwind-color\n```\n\n## Usage\n\nGenerate a random but deterministic Tailwind CSS color and shade from a string:\n\n```javascript\nimport { stringToTailwindColor } from 'string-to-tailwind-color';\n\nconst foo = stringToTailwindColor('foo');\nconsole.log(foo); // 'teal-500'\n\nconst bar = stringToTailwindColor('bar');\nconsole.log(bar); // 'emerald-100'\n```\n\nBy default all colors and shades are used - to use a subset of colors and/or shades, you can pass an options object as the second argument:\n\n```javascript\nimport { stringToTailwindColor } from 'string-to-tailwind-color';\n\nconst foo = stringToTailwindColor('foo', {\n  colors: ['red', 'green', 'blue'],\n  shades: [300, 500, 700],\n});\n\nconsole.log(foo); // 'red-300'\n```\n\n\u003e [!NOTE]\n\u003e For a full list of colors and shades see [https://tailwindcss.com/docs/colors](https://tailwindcss.com/docs/colors)\n\n\nIf you don't like the color generated for a particular string, you can use the `hashOffset` option to rotate the color (incrementing by 1 will give you a shade higher, decrementing by 1 will give you a shade lower, colors will also rotate):\n\n```javascript\nimport { stringToTailwindColor } from 'string-to-tailwind-color';\n\nconst a = stringToTailwindColor('foo');\nconsole.log(a); // 'teal-500'\n\nconst b = stringToTailwindColor('foo', { hashOffset: 1 });\nconsole.log(b); // 'teal-600'\n\nconst c = stringToTailwindColor('foo', { hashOffset: 11 });\nconsole.log(c); // 'cyan-500'\n```\n\nUse in combination with background color (`bg-`), text color (`text-`), border color (`border-`), etc:\n\n```javascript\nimport { stringToTailwindColor } from 'string-to-tailwind-color';\n\nconst SomeComponent = ({ text }) =\u003e {\n  const color = stringToTailwindColor(text);\n  return (\n    \u003cp className={`bg-${color} text-${color} border-${color}`}\u003e\n      {text}\n    \u003c/p\u003e\n  );\n};\n```\n\n\u003e [!NOTE]\n\u003e For a full list of classes compatible with colors see [https://tailwindcss.com/docs/colors#using-color-utilities](https://tailwindcss.com/docs/colors#using-color-utilities)\n\n## Use cases\n\nGenerate a color for a tag component based on it's contents:\n\n```javascript\nimport { stringToTailwindColor } from 'string-to-tailwind-color';\n\nconst Tag = ({ name }) =\u003e {\n  const color = stringToTailwindColor(name, {\n    colors: ['red', 'green', 'blue', 'yellow', 'purple', 'pink'],\n    shades: [300, 400, 500, 600, 700],\n  });\n  return (\n    \u003cspan className={`bg-${color} text-white px-2 py-1 rounded`}\u003e\n      {name}\n    \u003c/span\u003e\n  );\n};\n```\n\n\n## Development\n\n### Prerequisites\n\n- [Node.js](https://github.com/nodejs/node) (\u003e=18.x.x)\n- [pnpm](https://github.com/pnpm/pnpm) (\u003e=10.x.x)\n\n### Getting Started\n\nClone the repository and install dependencies:\n\n```sh\ngit clone https://github.com/jamieweavis/string-to-tailwind-color.git\n\ncd string-to-tailwind-color\n\npnpm install\n```\n\nRun all tests with [Vitest](https://github.com/vitest-dev/vitest):\n\n```sh\npnpm test\n```\n\nCheck the code for linting and formatting issues with [Biome](https://github.com/biomejs/biome):\n\n```sh\npnpm check\n```\n\nBuild the package with [Parcel](https://github.com/parcel-bundler/parcel):\n\n```sh\npnpm build\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjamieweavis%2Fstring-to-tailwind-color","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjamieweavis%2Fstring-to-tailwind-color","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjamieweavis%2Fstring-to-tailwind-color/lists"}