How can I organize the BEM styles in my Webflow site without needing to create combo classes and adjust properties in a specific order?

TL;DR
  • Use BEM naming convention for organizing class names (Block, Element, Modifier) in Webflow.
  • Avoid combo classes, instead create separate classes for blocks, elements, and modifiers.
  • Utilize Webflow tools like global swatches and symbols to ensure consistency and manage styles efficiently.

Effectively organizing BEM styles in Webflow can streamline your workflow and prevent the complications combo classes introduce. Here's how you can achieve this:

1. Understand BEM Naming Convention

  • BEM stands for Block, Element, Modifier.
  • Block: Represents the standalone component (e.g., .menu).
  • Element: A part of the block with no standalone meaning (e.g., .menu__item).
  • Modifier: A variant or state of a block or element (e.g., .menu__item--active).

2. Structure Your CSS in Webflow

  • Use BEM Naming: Incorporate the BEM naming convention directly into your Webflow class names.
  • Avoid Combo Classes: Since BEM inherently lends itself to specificity, it reduces the need for combo classes.

3. Create BEM Classes in Webflow

  • Blocks: Create a class in Webflow for each block component.
  • Elements: Use Webflow's class creation tool to make element classes. For instance, add a class named menu__item for each item in the menu block.
  • Modifiers: Use modifiers by creating a separate class to toggle styles and enhance dynamism while maintaining element-specific styles.

4. Manage Style Overrides and Consistency

  • Utilize Global Swatches: Global swatches can help maintain color consistency across different elements and modifiers.
  • Use Symbols for Reuse: Convert blocks into symbols when you need to reuse the same structure, ensuring consistency and easy updates.

5. Review and Maintain Structure

  • Regularly Audit Class Names: Keep your class names consistent and clean by regularly reviewing and refactoring if necessary.
  • Document Your Styles: Maintain documentation within your Webflow project to keep track of your BEM naming conventions and their purposes.

Summary

To organize BEM styles in Webflow effectively, avoid using combo classes and adhere to the BEM naming convention strictly. Create individual classes for blocks, elements, and modifiers. Use Webflow’s built-in tools like global swatches and symbols to maintain consistency and manage styles efficiently.

Rate this answer

Other Webflow Questions