useBem
useBem(
element,modifiers?,options?):string
Defined in: useBem.js:40
Build a BEM class name for a component.
The block comes from options.block when given (a string, or false to make
element a root), otherwise from context, and falls back to element itself
at the root. The hook only reads the current block; it never re-roots the
context for descendants — use withBem for that — so it’s safe to call
anywhere, e.g. recomputing class names from async state without prop drilling.
Every entry in modifiers is applied: true → --name, an array → one
--name_item per item, false/null/undefined → skipped, anything else →
--name_String(value) (a throwing toString is silently skipped).
Parameters
Section titled “Parameters”element
Section titled “element”string
modifiers?
Section titled “modifiers?”Record<string, unknown> = {}
Modifier name → value; every entry is applied (the caller controls exactly which modifiers are set).
options?
Section titled “options?”UseBemOptions = {}
Returns
Section titled “Returns”string
