{"id":23477345,"url":"https://github.com/vuebits/bem","last_synced_at":"2026-03-14T02:34:53.253Z","repository":{"id":53574062,"uuid":"315369285","full_name":"vuebits/bem","owner":"vuebits","description":"Simple implementation of BEM in Vue 3","archived":false,"fork":false,"pushed_at":"2021-03-23T15:36:44.000Z","size":302,"stargazers_count":4,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-28T08:41:17.417Z","etag":null,"topics":["bem","bem-css","bem-methodology","bem-naming","vue","vuejs","vuejs3"],"latest_commit_sha":null,"homepage":"","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/vuebits.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}},"created_at":"2020-11-23T16:08:35.000Z","updated_at":"2024-08-02T14:25:19.000Z","dependencies_parsed_at":"2022-08-22T11:00:49.152Z","dependency_job_id":null,"html_url":"https://github.com/vuebits/bem","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vuebits%2Fbem","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vuebits%2Fbem/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vuebits%2Fbem/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vuebits%2Fbem/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vuebits","download_url":"https://codeload.github.com/vuebits/bem/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248799715,"owners_count":21163398,"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","bem-css","bem-methodology","bem-naming","vue","vuejs","vuejs3"],"created_at":"2024-12-24T18:26:41.798Z","updated_at":"2026-03-14T02:34:48.209Z","avatar_url":"https://github.com/vuebits.png","language":"JavaScript","readme":"\u003ch1 align=\"center\"\u003eVue 3 BEM\u003c/h1\u003e\n\n\u003ch4 align=\"center\"\u003e*** Maintainers \u0026 Contributors welcome ***\u003c/h4\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://vuejs.org/\"\u003e\n    \u003cimg alt=\"Vue.js\" src=\"https://user-images.githubusercontent.com/18534115/100093526-f2794b80-2e57-11eb-9b2a-e24202e2904b.png\" height=\"192\"\u003e\n    \u003cimg alt=\"BEM\" src=\"https://user-images.githubusercontent.com/18534115/100067249-512dcd80-2e36-11eb-8f12-84b0fc1abfa1.png\" height=\"192\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n\u003ch4 align=\"center\"\u003eSimple implementation of \u003ca href=\"http://getbem.com/\"\u003eBEM\u003c/a\u003e in Vue 3.x\u003c/h4\u003e\n\u003cp\u003eBased on Vue 2.x library \u003ca href=\"https://github.com/c01nd01r/vue-bem-cn\"\u003evue-bem-cn\u003c/a\u003e\u003c/p\u003e\n\n---\n\n## Table of Contents\n\n* [Installation](#installation)\n* [API](#api)\n* [Documentation](#documentation)\n\n\n## Installation\n\n`npm i @vuebits/bem` / `yarn add @vuebits/bem`\n\nAnd install in your entry file (e.g. `main.js`):\n\n```javascript\nimport { createBem } from '@vuebits/bem';\n\ncreateApp(App).use(createBem({ /* your config here */ })).mount('#app');\n```\n\n## API\n\n### Available functions:\n\n* `createBem (options: BemOptions)`:\n\n```ts\ninterface BemOptions {\n  hyphenate?: boolean;\n}\n```\n\n### Vue instance properties and methods:\n\n* `$bem ({ b, e, m }: BemItem): string[]`:\n\n```ts\ninterface BemItem {\n  b?: string;\n  e?: string;\n  m?: string | string[] | {[key in string]: boolean};\n}\n```\n\n## Examples\n\n### Using component name by default:\n\n```vue\n\u003ctemplate\u003e\n  \u003cdiv :class=\"$bem({})\"\u003e \u003c!-- $bem({}) will return 'hello-world' --\u003e\n    Hello world!\n  \u003c/div\u003e\n\u003c/template\u003e\n\n\u003cscript lang=\"ts\"\u003e\nimport { defineComponent } from 'vue';\n\nexport default defineComponent({\n  name: 'hello-world'\n});\n\u003c/script\u003e\n\n\u003cstyle lang=\"scss\"\u003e\n.hello-world {\n  // some styles here\n}\n\u003c/style\u003e\n\n```\n\n### Using hyphenated component name:\n\nIf you use PascalCase naming convence you should init library with `hyphenate` option:\n\n```js\nimport { createBem } from '@vuebits/bem';\n\ncreateApp(App).use(createBem({\n  hyphenate: true\n})).mount('#app');\n```\n\nand then:\n\n```vue\n\u003ctemplate\u003e\n  \u003cdiv :class=\"$bem({})\"\u003e \u003c!-- returns ['hello-world'] --\u003e\n    Hello world!\n  \u003c/div\u003e\n\u003c/template\u003e\n\n\u003cscript lang=\"ts\"\u003e\nimport { defineComponent } from 'vue';\n\nexport default defineComponent({\n  name: 'HelloWorld'\n});\n\u003c/script\u003e\n\n\u003cstyle lang=\"scss\"\u003e\n.hello-world {\n  // some styles here\n}\n\u003c/style\u003e\n\n```\n\n### Custom block name:\n\n```vue\n\u003ctemplate\u003e\n  \u003cdiv :class=\"$bem({b: 'custom-block'})\"\u003e \u003c!-- returns ['custom-block'] --\u003e\n    Hello world!\n  \u003c/div\u003e\n\u003c/template\u003e\n\n\u003cscript lang=\"ts\"\u003e\nimport { defineComponent } from 'vue';\n\nexport default defineComponent({\n  name: 'HelloWorld'\n});\n\u003c/script\u003e\n\n\u003cstyle lang=\"scss\"\u003e\n.custom-block {\n  // some styles here\n}\n\u003c/style\u003e\n\n```\n\n### Element name:\n\n```vue\n\u003ctemplate\u003e\n  \u003cdiv :class=\"$bem({})\"\u003e \u003c!-- (or $bem({b: 'hello-world'})) - return ['hello-world'] --\u003e\n    \u003ch1 :class=\"$bem({e: 'title'})\"\u003e \u003c!-- (or $bem({b: 'hello-world', e: 'title'})) - returns ['hello-world__title'] --\u003e\n      Hello world!\n    \u003c/h1\u003e\n    \u003cp :class=\"$bem({e: 'description'})\"\u003e \u003c!-- (or $bem({b: 'hello-world', e: 'description'})) - returns ['hello-world__description'] --\u003e\n      This is a description\n    \u003c/p\u003e\n  \u003c/div\u003e\n\u003c/template\u003e\n\n\u003cscript lang=\"ts\"\u003e\nimport { defineComponent } from 'vue';\n\nexport default defineComponent({\n  name: 'HelloWorld'\n});\n\u003c/script\u003e\n\n\u003cstyle lang=\"scss\"\u003e\n.hello-world {\n  // some styles here\n  \u0026__title {\n    // some styles here\n  }\n  \u0026__description {\n    // some styles here\n  }\n}\n\u003c/style\u003e\n\n```\n\n### Inline modfiers:\n\n```vue\n\u003ctemplate\u003e\n  \u003cdiv :class=\"$bem({})\"\u003e \u003c!-- returns ['hello-world'] --\u003e\n    \u003cp :class=\"$bem({e: 'text', m: ['underlined']})\"\u003e \u003c!-- returns ['hello-world__text', 'hello-world__text--underlined'] --\u003e\n      This is a description\n    \u003c/p\u003e\n    \u003cp :class=\"$bem({e: 'text', m: ['underlined', 'highlighted']})\"\u003e \u003c!-- returns ['hello-world__text', 'hello-world__text--underlined', 'hello-world__text--highlighted'] --\u003e\n      This is a description\n    \u003c/p\u003e\n  \u003c/div\u003e\n\u003c/template\u003e\n\n\u003cscript lang=\"ts\"\u003e\nimport { defineComponent } from 'vue';\n\nexport default defineComponent({\n  name: 'HelloWorld'\n});\n\u003c/script\u003e\n\n\u003cstyle lang=\"scss\"\u003e\n.hello-world {\n  // some styles here\n  \u0026__text {\n    // some styles here\n    \u0026--underlined {\n      // some styles here\n    }\n    \u0026--highlighted {\n      // some styles here\n    }\n  }\n}\n\u003c/style\u003e\n\n```\n\n### Conditional modfiers:\n\n```vue\n\u003ctemplate\u003e\n  \u003cdiv :class=\"$bem({})\"\u003e \u003c!-- returns ['hello-world'] --\u003e\n    \u003cp :class=\"$bem({e: 'description', m: {underlined: true, highlighted: isHighlighted}})\"\u003e \u003c!-- returns ['hello-world__description', 'hello-world__description--underlined'] --\u003e\n      This is a description\n    \u003c/p\u003e\n  \u003c/div\u003e\n\u003c/template\u003e\n\n\u003cscript lang=\"ts\"\u003e\nimport { defineComponent } from 'vue';\n\nexport default defineComponent({\n  name: 'HelloWorld',\n  data () {\n    return {\n      isHighlighted: false\n    };\n  }\n});\n\u003c/script\u003e\n\n\u003cstyle lang=\"scss\"\u003e\n.hello-world {\n  // some styles here\n  \u0026__description {\n    // some styles here\n    \u0026--underlined {\n      // some styles here\n    }\n    \u0026--highlighted {\n      // some styles here\n    }\n  }\n}\n\u003c/style\u003e\n\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvuebits%2Fbem","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvuebits%2Fbem","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvuebits%2Fbem/lists"}