Best practices for styling your store

When integrating third-party widgets (like ours), it’s important to avoid style conflicts that can affect their functionality or appearance. Here are some best practices to structure your store's styles safely:

Avoid overly aggressive global resets

Global resets can unintentionally affect widgets, iframes, or external integrations.

 * {
   all: unset;
  }

  body, html {
    margin: 0;
    padding: 0;
    font-family: Arial !important;
  }  
.store * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
  } 

Don’t force global fonts

Changing the global font affects the entire DOM, including embedded widgets or libraries.

body {
    font-family: Arial !important;
  }  
.store {
    font-family: Arial;
  }

Control style specificity

Avoid overriding generic classes like .modal, .popup, or .overlay without proper context.

.modal {
    position: fixed;
    z-index: 9999;
    background: #fff;
  }
.store .modal {
    position: fixed;
    z-index: 1000;
    background: #fff;
  }

Handle z-index properly

Improper use of z-index can cause unexpected overlaps with widgets or other components.

 * {
    position: relative;
    z-index: 99999;
  }
 .header {
    z-index: 1000; /* Avoid extreme values unless strictly necessary. */
  }

Avoid global styles on base elements

Overriding basic HTML tags can affect widgets or third-party components.

button {
    border: none !important;
    background: transparent !important;
  }
.store-button {
    border: none;
    background: transparent;
  }

Use CSS variables for themes and colors

.store h1 {
    color: #ff6600;
    font-family: Arial, sans-serif;
  }
.store {
    --primary-color: #ff6600;
    --font-main: 'Arial', sans-serif;
  }

  .store .custom-title {
    color: var(--primary-color);
    font-family: var(--font-main);
  }

Use prefixed class names to avoid conflicts

Using common class names like .button, .icon, or .container without a namespace increases the risk of CSS collisions.

.button {
    padding: 10px;
  }
 .store-button {
    padding: 10px;
  }

Maintaining clean and well-scoped CSS is essential when working with third-party widgets or embedded components. Following these best practices helps ensure:

  • Your store’s styles remain consistent and predictable.

  • Third-party integrations work as expected, without visual or functional conflicts.

  • Maintenance becomes easier, reducing technical debt and avoiding hard-to-debug issues in the future.

Last updated