Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@format/bem

Package Overview
Dependencies
Maintainers
3
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@format/bem

BEM className generator adapted for React

  • 0.0.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
3
Created
Source

BEM

A small utility for creating old-school BEM classes, especially in a React context.

NOTE: Maintained for internal use only.

Quickstart

Given a component definition

import { bem } from "bem";

export const AlertBar = ({ level, message }) => {
  const b = bem("alert-bar");

  return (
    <div className={b.e("wrapper")}>
      <p className={b.e("message").m(level)}>{message}</p>
    </div>
  );
};

Rendering

<AlertBar message="Hello!" level="warning" />

Yields

<div class="alert-bar__wrapper">
  <p class="alert-bar__message alert-bar__message--warning">Hello!</p>
</div>

Examples

Simple Elements

  • bem('alert-bar').e('wrapper') yields "alert-bar__wrapper"

String Modifiers

  • bem('alert-bar').m('warning') yields "alert-bar alert-bar--warning"
  • bem('alert-bar').e('wrapper').m('warning') yields "alert-bar__wrapper alert-bar__wrapper--warning"

Array Modifiers

  • bem('alert-bar').m(['warning', 'condensed']) yields "alert-bar alert-bar--warning alert-bar--condensed"
  • bem('alert-bar').e('wrapper').m(['warning', 'condensed']) yields "alert-bar__wrapper alert-bar__wrapper--warning" alert-bar__wrapper--condensed

Object Modifiers

  • bem('alert-bar').m({ warning: true, condensed: true }) yields "alert-bar alert-bar--warning alert-bar--condensed"
  • bem('alert-bar').e('wrapper').m({ warning: true, expanded: false }) yields "alert-bar__wrapper alert-bar__wrapper--warning"

Keywords

FAQs

Package last updated on 03 Jun 2021

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc