🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

@digitalentities/react-hook-bem

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@digitalentities/react-hook-bem

BEM for React in the form of a higher-order component.

Source
npmnpm
Version
2.0.0
Version published
Weekly downloads
1
-99.49%
Maintainers
1
Weekly downloads
 
Created
Source

withBEM()

npm version GitHub checks

withBEM() implements the BEM methodology for React.

Installation

Use your favourite manager to install the package:

yarn add react-with-bem
npm install react-with-bem --save

Usage

import { BEM } from "react-with-bem";

// import styles as module (https://github.com/css-modules/css-modules)
import styles from "./App.module.scss";

// render
return (
  // activate BEM and inject styles
  <BEM styles={styles}>
    // set BEM block by using $block
    // output: <main class="app">
    <main $block="app">
      // set a BEM element by using $element
      // output: <div class="app__container">
      <div $element="container">
        // set BEM modifier by using $modifier (multiple modifiers are possible)
        // output:
        // <div class="app__container__click> when  clicked === false
        // <div class="app__container__click app__container__click--hidden"> when clicked === true
        <div
            $element="click"
            $modifier={{
              hidden: clicked,
            }}
        >
            Hello world!
        </div>
      </div>
    </main>
  </BEM>
);
.app {
    background-color: red;

    &__container {
        margin: 0 auto;

        &__click {
            &--hidden {
                display: none;
            }
        }
    }
}

Example

You can find a complete example here.

Keywords

react

FAQs

Package last updated on 18 Feb 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts