{"id":15046866,"url":"https://github.com/mukhindev/create-bem","last_synced_at":"2026-02-03T15:02:38.736Z","repository":{"id":147036513,"uuid":"618510359","full_name":"mukhindev/create-bem","owner":"mukhindev","description":"Utility for creating BEM class names. CSS Modules support.","archived":false,"fork":false,"pushed_at":"2023-10-07T22:32:40.000Z","size":78,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-08T22:19:54.854Z","etag":null,"topics":["bem","classnames","css","css-modules"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/mukhindev.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-24T16:14:25.000Z","updated_at":"2023-09-05T21:08:27.000Z","dependencies_parsed_at":"2024-11-14T04:11:54.404Z","dependency_job_id":null,"html_url":"https://github.com/mukhindev/create-bem","commit_stats":{"total_commits":4,"total_committers":1,"mean_commits":4.0,"dds":0.0,"last_synced_commit":"8749d65dbf78bb10e8f817f07dd2b0b19d4b7be3"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mukhindev/create-bem","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mukhindev%2Fcreate-bem","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mukhindev%2Fcreate-bem/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mukhindev%2Fcreate-bem/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mukhindev%2Fcreate-bem/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mukhindev","download_url":"https://codeload.github.com/mukhindev/create-bem/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mukhindev%2Fcreate-bem/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260512379,"owners_count":23020377,"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":["bem","classnames","css","css-modules"],"created_at":"2024-09-24T20:53:40.643Z","updated_at":"2026-02-03T15:02:33.704Z","avatar_url":"https://github.com/mukhindev.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Create BEM\n\nUtility for creating [BEM](https://bem.info/) class names. CSS Modules support.\n\n## BEM\n\n\u003cu\u003eB\u003c/u\u003elock, \u003cu\u003eE\u003c/u\u003element, \u003cu\u003eM\u003c/u\u003eodifier\n\nElements is a child of Block.\nModifiers refer of to Block or Element.\n\n`block-name`  \n`__element-name`  \n`_modifier-name` or `_modifier-key` `_modifier-value`  \n`mix-name`\n\n```html\n\u003clabel class=\"input\"\u003e\n  \u003cspan class=\"input__label\"\u003e\u003c/span\u003e\n  \u003cinput class=\"input__field input__field_disabled input__field_size_large\" /\u003e\n\u003c/label\u003e\n```\n\n## CSS\n\n```ts\nimport { createBem } from \"@mukhindev/create-bem\";\n\n// BEM-block (function)\nconst bem = createBem(\"input\");\n```\n\nbem(`element`, `modifier(s)`, `mix(es)`) return class names in BEM-style:\n\n```ts\nbem(); // input\nbem(\"label\"); // input__label\nbem(\"label\", \"active\"); // input__label input__label_active\nbem(\"label\", [\"active\", \"large\"]); // input__label input__label_active input__label_large\nbem(\"label\", { color: \"red\", large: false, active: true }); // input__label input__label_color_red input__label_active\nbem(\"\", { color: \"red\", large: false, active: true }); // input input_color_red input_active\nbem(\"\", \"\", \"main-page\"); // input main-page\nbem(\"label\", { color: \"red\" }, \"main-page\"); // input__label input__label_color_red main-page\n```\n\n## CSS Modules\n\nThe second argument to `createBem` is the object created by the CSS module:\n\n```ts\nimport { createBem } from \"@mukhindev/create-bem\";\nimport classes from \"./style.module.css\";\n\nconst bem = createBem(\"input\", classes);\n\nbem(\"label\", \"active\"); // _input__label_{hash} _input__label_active_{hash}\n```\n\nIf the css selector is undefined or empty, CSS modules ignore class generation. Utility `createBem` also ignores this selector:\n\n```ts\nbem(\"message\", \"\", \"mix\"); // \"mix\"\n```\n\nIf you find problems, check how your CSS selectors are hashed.\nHashed names should be converted like this:\n\n```\ninput -\u003e _input_{hash}\ninput__label -\u003e _input__label_{hash}\n```\n\n## Options\n\nOften the modifier is separated by `--`. The third argument to `createBem` is options:\n\n```ts\nconst bem = createBem(\"input\", undefined, { modifierKeyDivider: \"--\" });\n```\n\nDefault options:\n\n```ts\n                             ↓\nelementDivider: \"__\" // input__field_size_large\n                                        ↓                          ↓\nmodifierKeyDivider: \"_\" //  input__field_size_large or input__field_active\n                                              ↓\nmodifierValueDivider: \"_\" // input__field_size_large\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmukhindev%2Fcreate-bem","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmukhindev%2Fcreate-bem","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmukhindev%2Fcreate-bem/lists"}