{"id":13397678,"url":"https://github.com/franzheidl/bemify","last_synced_at":"2025-04-08T03:13:46.856Z","repository":{"id":30548830,"uuid":"34103564","full_name":"franzheidl/bemify","owner":"franzheidl","description":"Sass Mixins to write BEM-style SCSS source","archived":false,"fork":false,"pushed_at":"2020-02-21T14:29:59.000Z","size":31,"stargazers_count":146,"open_issues_count":1,"forks_count":7,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-31T18:21:35.895Z","etag":null,"topics":["bem","bem-methodology","css","sass","sass-mixins"],"latest_commit_sha":null,"homepage":"","language":"HTML","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/franzheidl.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":"2015-04-17T07:47:20.000Z","updated_at":"2024-06-17T08:56:07.000Z","dependencies_parsed_at":"2022-08-29T10:02:22.618Z","dependency_job_id":null,"html_url":"https://github.com/franzheidl/bemify","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/franzheidl%2Fbemify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/franzheidl%2Fbemify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/franzheidl%2Fbemify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/franzheidl%2Fbemify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/franzheidl","download_url":"https://codeload.github.com/franzheidl/bemify/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247767236,"owners_count":20992548,"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-methodology","css","sass","sass-mixins"],"created_at":"2024-07-30T18:01:38.713Z","updated_at":"2025-04-08T03:13:46.836Z","avatar_url":"https://github.com/franzheidl.png","language":"HTML","funding_links":[],"categories":["HTML"],"sub_categories":[],"readme":"# bemify\n\n[![Bower Version](https://img.shields.io/bower/v/bemify.svg)](http://bower.io/search/?q=bemify)\n[![Gem Version](https://img.shields.io/gem/v/bemify.svg)](https://rubygems.org/gems/bemify)\n[![npm Version](https://img.shields.io/npm/v/bemify.svg)](https://www.npmjs.com/package/bemify)\n\nBemify is a set of Sass mixins to help you write well-structured, readable, maintainable, component-based modular SCSS source using a BEM-style syntax.\n\n__Bemify site \u0026 documentation: [http://franzheidl.github.io/bemify/](http://franzheidl.github.io/bemify/)__\n\nBemify supports [libsass](https://github.com/sass/libsass) since libsass 3.2.4.\n## Install\n\nBemify can be installed as a [Ruby Gem](https://rubygems.org/gems/bemify), via [Bower](http://bower.io/search/?q=bemify), [NPM](https://www.npmjs.com/package/bemify), or manually. As a NPM module, bemify supports [eyeglass](https://github.com/sass-eyeglass/eyeglass). Bemify is also on [Sache.in](http://www.sache.in/search?query=bemify).\n\n\n### Bower\nTo install via bower run:\n\n    $ bower install bemify --save-dev\n\n### Ruby Gem\nWhen installed as a Ruby Gem, Bemify will be installed as a Compass extension if Compass is installed on your system.\n\n    $ gem install bemify\n\n### npm\nTo install via npm run:\n\n    $npm install bemify --save-dev\n\n### Manual Install\nInclude `sass/_bemify.scss`in the appropriate location in your project.\n\n\n\n## Usage\nFirst, import bemify:\n\n    @import 'bemify';\n\n\nOnce imported, the bemify mixins can now be used to write BEM-style SCSS, making your source cleaner and easier to read and change.\n\n    @include block('my-element') {\n        …\n\n        @include element('child') {\n          …\n        }\n\n        @include modifier('small') {\n          …\n        }\n\n        @include modifier('large') {\n          …\n        }\n\n        @include state('active') {\n          …\n        }\n\n    }\n\nThe output will be full, non-nested BEM-style class selectors:\n\n\n    .my-element {\n      …\n    }\n\n    .my-element__child {\n      …\n    }\n\n    .my-element--large {\n      …\n    }\n\n    .my-element.is-active {\n      …\n    }\n\nBy default, bemify will output combined `.block.state` / `.block__element.state` selectors.\nBemify can also be configured to output full `.block--state` / `.block__element--state` selectors.\nFor details, see Configuration below.\n\n\nThe mixins can be nested to create modifiers for subcomponents:\n\n    @include block('my-element') {\n\n        @include element('child') {\n            …\n            @include modifier('bad') {\n                …\n                @include state('happy') {\n                    …\n                }\n            }\n        }\n\n        @include modifier('large') {\n            …\n        }\n\n        @include state('active') {\n            …\n        }\n\n    }\n\nThis will result in:\n\n    .my-element {\n        …\n    }\n\n    .my-element__child {\n        …\n    }\n\n    .my-element__child--bad {\n        …\n    }\n\n    .my-element__child--bad.is-happy {\n        …\n    }\n\n    .my-element--large {\n        …\n    }\n\n    .my-element.is-active {\n\n    }\n\n### Scoping\n\nBemify can of course also be used inside any scope:\n\n\t.scope {\n\n\t\t@include block('nav') {\n\n\t\t\t// etc.\n\n\t\t}\n\n\t}\n\n\n### Configuration Options\n\nbemify uses some configuration variables where to adjust the block-element and the state separator, as well as the state prefix.\nTo overwrite bemify's config with your own configuration file, just import your variables before using one of the mixins.\n\n    @import \"your-variables\";\n    @import \"bemify\";\n\n    @include block('my-block') {\n        …\n    }\n\n\nConfigurable options and their defaults are:\n\n* `$combined-state-selectors`: `true`\n\n  Will output selectors like: .element.is-active, set to false to write .element--is-active\n\n* `$element-separator`: `__`\n\n* `$modifier-separator`: `--`\n\n* `$state-prefix`: `is`\n\n  Note that `$state-prefix` can be overridden with each call to the `state` mixin, so you can use both `--is-active` and `--has-error` using the same configuration:\n\n      @include state('error', 'has') {}\n\n\n## Aliases\nNot everyone thinks in the categories of 'block, element, modifier', but many of us still want to write modularized, components-based CSS. There are a couple of aliases included for those who think in terms of components, parent-child / -subcomponents included (And it's totally straightforward to add your own):\n\n    @include block('name') {}\n        == @include component('name') {}\n\n    @include element('name') {}\n        == @include child('name') {}\n        == @include subcomponent('name') {}\n        == @include sub('name') {}\n\n\n\n\n\n## Resources\nSome highly recommended reading re CSS structure, decoupling markup and styles, BEM, and why this makes sense:\n\n\n* [Nicolas Gallagher: About HTML semantics and front-end architecture](http://nicolasgallagher.com/about-html-semantics-front-end-architecture/)\n* [Philip Walton: Side Effects in CSS](http://philipwalton.com/articles/side-effects-in-css/)\n* [BEM official](http://getbem.com/)\n* [Harry Roberts: MindBEMding – getting your head ’round BEM syntax](http://csswizardry.com/2013/01/mindbemding-getting-your-head-round-bem-syntax/)\n\n\n\n---\nThe MIT License (MIT)\n\nCopyright (c) 2015 Franz Heidl\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffranzheidl%2Fbemify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffranzheidl%2Fbemify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffranzheidl%2Fbemify/lists"}