Skip to content

bem

bem<T>(config): (value, context) => T

Defined in: lit/src/bem.js:85

Standard (TC39) class decorator that makes a custom element a BEM component — the Lit / web-components analog of @bem-broom/react’s withBem. It:

  • reads the block from context (an ancestor’s element, or none at the root),
  • applies the computed BEM class(es) to the host element,
  • provides config.element as the block for descendants (re-rooting),
  • recomputes on modifier-property or context change (on Lit hosts).

Apply it below @customElement so the element is defined with the wrapped class:

@customElement('bb-card')
@bem({ element: 'card', modifiers: ['active'] })
class Card extends LitElement { … }

T extends (…args) => HTMLElement

BemDecoratorConfig

(value, context) => T