{"id":44358812,"url":"https://github.com/hoangnhan2ka3/twg","last_synced_at":"2026-03-01T08:00:52.636Z","repository":{"id":253553215,"uuid":"843848284","full_name":"hoangnhan2ka3/twg","owner":"hoangnhan2ka3","description":"🪥 A utility function for grouping TailwindCSS variants.","archived":false,"fork":false,"pushed_at":"2026-02-19T15:55:46.000Z","size":2005,"stargazers_count":2,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-19T16:48:27.840Z","etag":null,"topics":["classnames","clsx","grouping-variants","tailwind","tailwind-variants","tailwind-variants-grouping","tailwindcss","tailwindcss-plugin","variants-grouping"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/twg","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hoangnhan2ka3.png","metadata":{"files":{"readme":".github/README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","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},"funding":{"github":"hoangnhan2ka3","buy_me_a_coffee":"hoangnhan2ka3"}},"created_at":"2024-08-17T15:50:53.000Z","updated_at":"2026-02-19T12:30:30.000Z","dependencies_parsed_at":"2024-08-17T17:02:13.723Z","dependency_job_id":"f2e85ae3-5fdf-4129-bda9-4039739ecde2","html_url":"https://github.com/hoangnhan2ka3/twg","commit_stats":null,"previous_names":["hoangnhan2ka3/twg"],"tags_count":49,"template":false,"template_full_name":null,"purl":"pkg:github/hoangnhan2ka3/twg","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoangnhan2ka3%2Ftwg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoangnhan2ka3%2Ftwg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoangnhan2ka3%2Ftwg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoangnhan2ka3%2Ftwg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hoangnhan2ka3","download_url":"https://codeload.github.com/hoangnhan2ka3/twg/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoangnhan2ka3%2Ftwg/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29962004,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-01T05:59:08.471Z","status":"ssl_error","status_checked_at":"2026-03-01T05:58:04.208Z","response_time":124,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5: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":["classnames","clsx","grouping-variants","tailwind","tailwind-variants","tailwind-variants-grouping","tailwindcss","tailwindcss-plugin","variants-grouping"],"created_at":"2026-02-11T17:07:09.699Z","updated_at":"2026-03-01T08:00:52.532Z","avatar_url":"https://github.com/hoangnhan2ka3.png","language":"TypeScript","funding_links":["https://github.com/sponsors/hoangnhan2ka3","https://buymeacoffee.com/hoangnhan2ka3","https://www.buymeacoffee.com/hoangnhan2ka3","https://img.buymeacoffee.com/button-api/?text=Buy"],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"../public/twg_cover.webp\" alt=\"TWG Cover\"\u003e\n\u003c/div\u003e\n\n\u003ch1 align=\"center\"\u003etwg\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/hoangnhan2ka3/twg/actions\"\u003e\u003cimg src=\"https://badgen.net/github/checks/hoangnhan2ka3/twg/main?label=tests\u0026color=f279b6\" alt=\"Tests Status\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/hoangnhan2ka3/twg\"\u003e\u003cimg src=\"https://badgen.net/github/stars/hoangnhan2ka3/twg?color=f279b6\" alt=\"Repository stars\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://bundlejs.com/?q=twg\"\u003e\u003cimg src=\"https://badgen.net/bundlejs/min/twg?label=bundle\u0026color=f279b6\" alt=\"Bundle Size\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://bundlejs.com/?q=twg\"\u003e\u003cimg src=\"https://badgen.net/bundlejs/minzip/twg?label=gzip\u0026color=f279b6\" alt=\"Gzip Size\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/twg\"\u003e\u003cimg src=\"https://badgen.net/npm/dt/twg?color=f279b6\" alt=\"Total Downloads\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/twg\"\u003e\u003cimg src=\"https://badgen.net/npm/v/twg?color=f279b6\" alt=\"Latest Release\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/twg/twg/blob/main/LICENSE\"\u003e\u003cimg src=\"https://badgen.net/npm/license/twg?color=f279b6\" alt=\"License\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://www.npmjs.com/package/twg?activeTab=dependencies\"\u003e\u003cimg src=\"https://badgen.net/badge/dependencies/1?color=f279b6\" alt=\"Dependency Count\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://bundlephobia.com/result?p=twg\"\u003e\u003cimg src=\"https://badgen.net/badge/tree-shaking/supported?color=f279b6\" alt=\"Tree Shakable Supports\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003ch3 align=\"center\"\u003e\n🪥 A utility function for grouping Tailwind CSS variants.\n\u003c/h3\u003e\n\n\u003ch4 align=\"center\"\u003e\nA more elegant way of writing Tailwind classes. Never need to repeating the same variants over and over again 🤯.\n\u003c/h4\u003e\n\n---\n\n\u003cdiv align=\"center\"\u003e\n\n| 📍 Entry point  | 📦 Bundle |  📦 Gzip   |\n| :-------------- | :-------: | :--------: |\n| `twg`           |   732 B   | **413 B**  |\n| `twg/transform` |  3676 B   | **1497 B** |\n\n\u003c/div\u003e\n\n---\n\n## 🗝️ Features\n\n- ✅ Support for normal strings.\n- ✅ Support for multiple objects parsing.\n- ✅ Support for nesting multiple objects, arrays, and itself functions.\n- ✅ Support for (multiple) conditional classes, objects, and arrays.\n- ✅ Customizable `callee` name and `separator`.\n- ✅ Compatible with wrappers like [`twMerge`](https://github.com/dcastil/tailwind-merge).\n- ✅ \"Base\" support for Tailwind CSS IntelliSense (IDEs extension), as well as [Hover Preview](https://marketplace.visualstudio.com/items?itemName=bradlc.vscode-tailwindcss#hover-preview).\n- ✅ Tree-shaking friendly.\n\n---\n\n## 📃 Support\n\n| Framework     | Version |\n| :------------ | :------ |\n| `tailwindcss` | `3.x`   |\n\n\u003e [!NOTE]\n\u003e Tailwind CSS `v4` is not supported. Because they removed [`content.transform`](https://v3.tailwindcss.com/docs/content-configuration#transforming-source-files) API.\n\u003e Currently, there is no way to intervene before Tailwind scans the classes.\n\n---\n\n## 📌 Table of contents\n\n- [Quick intro](#-quick-intro)\n- [Getting started](#-getting-started)\n- [More on docs](#-docs)\n- [Changelog](#-changelog)\n- [Contributing](#-contributing)\n- [Credits](#-credits)\n\n---\n\n## 🚨 Quick intro\n\nExample:\n\n```jsx\n\u003cdiv\n  className={twg(\"size-92 relative grid place-items-center\", {\n    before: \"absolute inset-0 bg-red-500\",\n    \"aria-expanded\": \"bg-red-500 text-yellow-500\"\n  })}\n\u003e\n  Hello, World!\n\u003c/div\u003e\n```\n\nOutput (html):\n\n```jsx\n\u003cdiv class=\"size-92 relative grid place-items-center before:absolute before:inset-0 before:bg-red-500 aria-expanded:bg-red-500 aria-expanded:text-yellow-500\"\u003e\n  Hello, World!\n\u003c/div\u003e\n```\n\n\u003e [!TIP]\n\u003e Simply open an Object, put the `variant` as key, and classes you want to map to that `variant` as each value.\n\u003e See [usage / use cases](../docs/usage.md) for more details.\n\n---\n\n## 🚀 Getting started\n\n**1. Install the package**\n\n```bash\npnpm add twg\n```\n\nor\n\n```bash\nnpm install twg\n```\n\n**2. Setup**\n\n```js\n// tailwind.config.ts\n\nimport { type Config } from \"tailwindcss\"\nimport { transformer } from \"twg/transform\"\n\nexport default {\n  content: {\n    files: [\n      \"./src/app/**/*.{ts,tsx}\",\n      \"./src/components/**/*.{ts,tsx}\",\n      \"./src/content/**/*.mdx\"\n    ], // Move your old `content` to `content.files` like this\n    transform: {\n      DEFAULT: transformer() // Put `transformer()` here\n    }\n  },\n  // ...\n} satisfies Config\n```\n\n- If you need to override default `transformer()` options:\n\n  ```js\n  transform: {\n    DEFAULT: transformer({\n      // Define options here, eg.:\n      callee: \"cn\"\n    })\n  }\n  ```\n\n  See all [options](../docs/options.md#-default-version) and how to [custom options](../docs/options.md#-custom-options).\n\n**3. Usage**\n\n```jsx\nimport { twg } from \"twg\"\n```\n\n- If you need to override default `twg()` options, you need to use `createTwg()` function:\n\n  ```js\n  import { createTwg } from \"twg\"\n\n  createTwg({ separator: \"_\" })(...inputs)\n  //...\n  ```\n\n  See [custom `separator`](../docs/options.md#-custom-separator).\n\nFor more information, consider reading [custom options](../docs/options.md#-custom-options) ↗️ and [best practice](../docs/usage.md#best-practice-with-twmerge) ↗️.\n\nSee [how to use](../docs/usage.md) on docs 👇.\n\n---\n\n## 📚 Docs\n\n- [Usage / Use cases](../docs/usage.md) ↗️\n  - [Usage](../docs/usage.md#-usage) ↗️\n    - [Basic usage](../docs/usage.md#-basic-usage) ↗️\n    - [Complex as ☠️ usage](../docs/usage.md#-complex-as-%EF%B8%8F-usage) ↗️\n  - [Use cases](../docs/usage.md#-use-cases) ↗️\n    - [Conditionals](../docs/usage.md#-conditionals) ↗️\n    - [Nesting callee functions](../docs/usage.md#-nesting-callee-functions) ↗️\n  - [Combination](../docs/usage.md#-combination) ↗️\n- [Options](../docs/options.md) ↗️\n  - [`transformer()` options](../docs/options.md#transformer-options) ↗️\n  - [`createTwg()` options](../docs/options.md#createtwg-options) ↗️\n  - [Custom options](../docs/options.md#-custom-options) ↗️\n    - [Custom `callee`](../docs/options.md#-custom-callee) ↗️\n    - [Custom `separator`](../docs/options.md#-custom-separator) ↗️\n    - [Turn on `debug`](../docs/options.md#-turn-on-debug) ↗️\n- [API](../docs/api.md) ↗️\n- [Deeper explanation](../docs/introduction.md) ↗️\n  - [What is `twg`?](../docs/introduction.md#-what-is-twg) ↗️\n  - [Explanation](../docs/introduction.md#%EF%B8%8F-explanation) ↗️\n  - [Trade-offs](../docs/introduction.md#-trade-offs) ↗️\n\n## 🎉 Changelog\n\nFor full \u0026 latest update changelog, please refer to [CHANGELOG.md](../CHANGELOG.md).\n\n## 💎 Contributing\n\n### Bugs\n\n`twg` now work for me but maybe not for you in some edges. Consider opening an [issue](https://github.com/hoangnhan2ka3/twg/issues) if you have any problem with it that I can fix it ASAP. Or a [pull request](https://github.com/hoangnhan2ka3/twg/pulls) is welcome too.\n\n### Features\n\nIf you have any ideas, feel free to open a [feature request](https://github.com/hoangnhan2ka3/twg/issues/new/choose) template or make a [pull request](https://github.com/hoangnhan2ka3/twg/pulls) to share your ideas.\n\n\u003e For **Development** and more information on contributing please read [CONTRIBUTING.md](../CONTRIBUTING.md).\n\n## 🪪 Credits\n\n### References\n\n- [easy-tailwind](https://github.com/Noriller/easy-tailwind) ↗️\n- [clsx](https://github.com/lukeed/clsx) ↗️\n- [tailwind-merge](https://github.com/dcastil/tailwind-merge) ↗️\n- [`content.transform` API](https://v3.tailwindcss.com/docs/content-configuration#transforming-source-files) ↗️\n\n### Project starts on\n\n- August 15, 2024\n\n### 💪 Work with me\n\n\u003chttps://www.linkedin.com/in/hoangnhan2ka3/\u003e\n\n### Funding\n\n[![Donate me](https://img.shields.io/static/v1?label=Donate%20me\u0026message=❤️\u0026style=social)](https://github.com/sponsors/hoangnhan2ka3)\n\n\u003ca href=\"https://www.buymeacoffee.com/hoangnhan2ka3\"\u003e\u003cimg src=\"https://img.buymeacoffee.com/button-api/?text=Buy me a beer\u0026emoji=🍺\u0026slug=hoangnhan2ka3\u0026button_colour=FFDD00\u0026font_colour=000000\u0026font_family=Poppins\u0026outline_colour=000000\u0026coffee_colour=ffffff\" /\u003e\u003c/a\u003e\n\n---\n\n\u003cdiv align=\"center\" width=\"100%\"\u003e\n  \u003ctable\u003e\n    \u003ctr\u003e\n      \u003cth width=\"500px\"\u003e\n        \u003cdiv align=\"start\"\u003e\n          \u003ca href=\"#-getting-started\"\u003eGetting started\u003c/a\u003e\n        \u003c/div\u003e\n      \u003c/th\u003e\n      \u003cth width=\"500px\"\u003e\n        \u003cdiv align=\"center\"\u003e\n          MIT © \u003ca href=\"https://github.com/hoangnhan2ka3\"\u003eNguyễn Hoàng Nhân\u003c/a\u003e\n        \u003c/div\u003e\n      \u003c/th\u003e\n      \u003cth width=\"500px\"\u003e\n        \u003cdiv align=\"end\"\u003e\n          \u003ca href=\"#\"\u003eScroll to top\u003c/a\u003e\n        \u003c/div\u003e\n      \u003c/th\u003e\n    \u003c/tr\u003e\n  \u003c/table\u003e\n\u003c/div\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhoangnhan2ka3%2Ftwg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhoangnhan2ka3%2Ftwg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhoangnhan2ka3%2Ftwg/lists"}