Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      Error’d: You Talkin’ to Me?

      September 20, 2025

      The Psychology Of Trust In AI: A Guide To Measuring And Designing For User Confidence

      September 20, 2025

      This week in AI updates: OpenAI Codex updates, Claude integration in Xcode 26, and more (September 19, 2025)

      September 20, 2025

      Report: The major factors driving employee disengagement in 2025

      September 20, 2025

      Development Release: Zorin OS 18 Beta

      September 19, 2025

      Distribution Release: IPFire 2.29 Core 197

      September 19, 2025

      Development Release: Ubuntu 25.10 Beta

      September 18, 2025

      Development Release: Linux Mint 7 Beta “LMDE”

      September 18, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      Student Performance Prediction System using Python Machine Learning (ML)

      September 21, 2025
      Recent

      Student Performance Prediction System using Python Machine Learning (ML)

      September 21, 2025

      The attack on the npm ecosystem continues

      September 20, 2025

      Feature Highlight

      September 20, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      Hyprland Made Easy: Preconfigured Beautiful Distros

      September 20, 2025
      Recent

      Hyprland Made Easy: Preconfigured Beautiful Distros

      September 20, 2025

      Development Release: Zorin OS 18 Beta

      September 19, 2025

      Distribution Release: IPFire 2.29 Core 197

      September 19, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»Development»How to Write Media Queries in Optimizely Configured Commerce (Spire)

    How to Write Media Queries in Optimizely Configured Commerce (Spire)

    August 6, 2025

    Media queries are essential for modern websites. They enable responsive design by allowing your site or UI to adapt seamlessly across different device sizes. In this blog, we’ll explore how to implement media queries in Optimizely Spire and how to update or customize breakpoints to suit your design needs.

    Let’s get started!

    Setting Up Breakpoints

    First, we’ll define breakpoints based on our style guide. Breakpoints help your website adjust its layout depending on the screen size, such as mobile, tablet, or desktop.

    In Optimizely Spire, breakpoints are defined within the theme configuration file. To update these breakpoints in the base code, you need to create a Start.tsx file—if it hasn’t been made already.

    Path: modules/blueprints/CustomBlueprint/src/Start.tsx

    Where to Place Breakpoint Configuration

    Place the breakpoint configuration within either the setPreStyleGuideTheme or setPostStyleGuideTheme functions. These functions allow you to customize the theme before or after the default style guide is applied.

    This setup ensures that your custom breakpoints are recognized and used consistently throughout your application.

    Below is the configuration structure for setting custom breakpoints in Optimizely Spire:

    Breakpoint Configured commerce

    Understanding the Breakpoint Configuration

    To make your site responsive, you define breakpoints—specific screen widths where your layout should adapt. Here’s what each part of the configuration means:

    • Keys – Represent screen size labels such as:

    These are shorthand names for different device sizes:

      • xs – Extra small (e.g., small phones)
      • sm – Small (e.g., larger phones)
      • md – Medium (e.g., tablets)
      • lg – Large (e.g., small laptops)
      • xl – Extra large (e.g., large desktops)
    • Values – Minimum Widths

    These define when each screen size category starts:

      • xs starts at 0px
      • sm starts at 576px
      • md starts at 768px
      • lg starts at 992px
      • xl starts at 1200px
    • Max Widths – Content Limits

    These define the maximum width the content area can grow to at each breakpoint. Even if the screen is wider, the content won’t stretch beyond these limits (example: 1140px for xl).

    Think of it like this:

    • On a phone → small screen → use xs styles
    • On a tablet → medium screen → use md styles
    • On a laptop or desktop → big screen → use lg or xl styles

    Creating Media Queries in a Standardized Way

    To create media queries in Optimizely Spire, we rely on the breakpoint configuration defined earlier. This ensures consistency across the application and simplifies responsive design.

    How It Works

    Behind the scenes, Spire uses a utility called breakpointMediaQueries to convert standardized media query definitions into browser-readable CSS.

    Utility Location:  modulesmobiussrcutilitiesbreakpointMediaQueries.ts

    This utility helps generate clean and consistent media queries based on your defined breakpoints.

    Available Media Query Types:

    Here are three types of media query options available:

    • min – Applies styles when the screen is at or above a certain width.
    • max – Applies styles when the screen is at or below a certain width.
    • minMax – Applies styles between two specific widths.

    Default Media Query Structure

    Here’s what a typical media query definition looks like using this utility:

    Media query structure configured commerce

    Now let’s see how this media query utility works with min, max, and minMax.

    • min

    The min-width media query structure will be as follows:

    Min Width media query configured commerce

     Example: To apply styles for min-width: 576px, insert your CSS code in the appropriate section.                                               Min Width media query example configured commerce

    Similarly, if you want to apply CSS for min-width: 768px, just replace the respective null with your CSS code.

    • max

    The max-width media query structure will be as follows:

    Max Width media query configured commerce

    Example: To apply styles for max-width: 575px, insert your CSS code in the appropriate section.Max Width media query example configured commerce

    Similarly, if you want to apply CSS for max-width: 767px, just replace the respective null with your CSS code.

    • minMax

    The minMax media query structure will be as follows:minMax Width media query example configured commerce

    Example: To apply styles between min-width: 576px and max-width: 767px, insert your CSS code in the appropriate section.minMax Width media query example configured commerce

     

    Similarly, if you want to create media queries for other screen sizes, follow the same approach as described above.

    You can also define multiple CSS rules as shown in the examples below.

    With Multiple Css Option configured commerce

    Conclusion

    Creating responsive layouts doesn’t have to be complicated or repetitive. A utility like breakpointMediaQueries helps you apply consistent styling logic throughout your application. Whether you use a mobile-first (min), desktop-first (max), or range-based (minMax) approach, this system lets you apply styles exactly where they’re needed.

    By simplifying the media query logic, your code becomes easier to read and maintain, so you can focus more on design and less on repetitive code. Choose the approach that best fits your project, and let your breakpoints handle the rest.

     

    Source: Read More 

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleBuilding a Custom API with Node.js
    Next Article JavaScript vs C#: How to Choose the Right Language as a Beginner

    Related Posts

    Development

    Student Performance Prediction System using Python Machine Learning (ML)

    September 21, 2025
    Development

    The attack on the npm ecosystem continues

    September 20, 2025
    Leave A Reply Cancel Reply

    For security, use of Google's reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use.

    Continue Reading

    CVE-2025-36528 – Zohocorp ManageEngine ADAudit Plus SQL Injection Vulnerability

    Common Vulnerabilities and Exposures (CVEs)

    CVE-2024-41505 – Jetimob Plataforma Imobiliaria XSS in Pessoas Profisso Field

    Common Vulnerabilities and Exposures (CVEs)

    CVE-2025-48844 – QNAP NAS Denial of Service

    Common Vulnerabilities and Exposures (CVEs)

    How to Test Junior Laravel Developer Skills: Sample Project

    Development

    Highlights

    Linux

    New RISC-V SBC Supports Ubuntu 24.04, But Won’t Run Future Releases

    July 16, 2025

    ESWIN EBC77 RISC-V SBC launches with Ubuntu 24.04 LTS support but RVA20 profile means it…

    I brought Samsung’s rugged Galaxy tablet on a hiking trip, and it weathered everything

    August 17, 2025

    High-Severity Flaw in HashiCorp Nomad (CVE-2025-4922) Allows Privilege Escalation

    June 12, 2025

    CVE-2024-12498 – CVE-2021-42251: Apache Struts Deserialization Remote Code Execution

    July 16, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.