{"id":19982366,"url":"https://github.com/netlify/classnames-template-literals","last_synced_at":"2026-03-16T09:03:38.623Z","repository":{"id":47628395,"uuid":"343910631","full_name":"netlify/classnames-template-literals","owner":"netlify","description":"Small utility to format long classnames with template literals","archived":false,"fork":false,"pushed_at":"2023-05-28T05:34:24.000Z","size":59,"stargazers_count":75,"open_issues_count":2,"forks_count":3,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-06-22T04:34:28.484Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/netlify.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}},"created_at":"2021-03-02T20:58:14.000Z","updated_at":"2024-12-14T07:27:37.000Z","dependencies_parsed_at":"2024-06-18T19:59:07.895Z","dependency_job_id":null,"html_url":"https://github.com/netlify/classnames-template-literals","commit_stats":{"total_commits":8,"total_committers":3,"mean_commits":"2.6666666666666665","dds":0.375,"last_synced_commit":"357dd154c74089e4bee1901b22dc5b69416c0a2b"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/netlify/classnames-template-literals","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netlify%2Fclassnames-template-literals","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netlify%2Fclassnames-template-literals/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netlify%2Fclassnames-template-literals/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netlify%2Fclassnames-template-literals/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/netlify","download_url":"https://codeload.github.com/netlify/classnames-template-literals/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netlify%2Fclassnames-template-literals/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261338948,"owners_count":23143891,"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-13T04:10:58.534Z","updated_at":"2025-10-06T09:03:06.194Z","avatar_url":"https://github.com/netlify.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# classnames-template-literals\n\nUtility originally created to deal with long Tailwind classnames.\n\nTo make our code more readable, we extract our Tailwind classes into variables, for example:\n\n```javascript\nconst twClasses = `\n  tw-sr-only \n  focus:tw-not-sr-only \n  tw-bg-teal-darker \n  tw-text-white \n  tw-block\n  tw-text-sm\n  tw-l-0\n`;\n```\n\nThe issue with writing classes this way is that they are rendered as-is in the DOM.\n\nExample:\n\n```javascript\n\u003cp\n  class=\"\n  tw-sr-only\n  focus:tw-not-sr-only\n  tw-bg-teal-darker\n  tw-text-white\n  tw-block\n  tw-text-sm\n  tw-l-0\"\n\u003e\n  Hello world\n\u003c/p\u003e\n```\n\nUsing the `ctl` util formats classnames so they are rendered in a more standard way in the DOM.\n\nExample:\n\n```javascript\n\u003cp class=\"tw-sr-only focus:tw-not-sr-only tw-bg-teal-darker tw-text-white tw-block tw-text-sm tw-l-0\"\u003e\n  Hello world\n\u003c/p\u003e\n```\n\n## Installation\n\n```javascript\nnpm install @netlify/classnames-template-literals\n```\n\n## Usage\n\nWrap your classnames inside `ctl`.\n\n```javascript\nimport ctl from \"@netlify/classnames-template-literals\";\n\nconst buttonClasses = ctl(`\n    bg-black\n    text-white\n    p-1\n    rounded-sm\n`);\n```\n\nYou can also use conditional classes:\n\n```javascript\nimport ctl from \"@netlify/classnames-template-literals\";\n\nconst buttonClasses = ctl(`\n    bg-black\n    text-white\n    p-1\n    rounded-sm\n    ${someState \u0026\u0026 \"bg-pink\"}\n`);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetlify%2Fclassnames-template-literals","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnetlify%2Fclassnames-template-literals","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetlify%2Fclassnames-template-literals/lists"}