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

      The Power Of The Intl API: A Definitive Guide To Browser-Native Internationalization

      August 8, 2025

      This week in AI dev tools: GPT-5, Claude Opus 4.1, and more (August 8, 2025)

      August 8, 2025

      Elastic simplifies log analytics for SREs and developers with launch of Log Essentials

      August 7, 2025

      OpenAI launches GPT-5

      August 7, 2025

      5 ways business leaders can transform workplace culture – and it starts by listening

      August 8, 2025

      My 4 favorite image editing apps on Linux – and two are free Photoshop alternatives

      August 8, 2025

      How Google’s Genie 3 could change AI video – and let you build your own interactive worlds

      August 8, 2025

      How you’re charging your tablet is slowly killing it – 3 methods to avoid (and the right way)

      August 8, 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

      Establishing Consistent Data Foundations with Laravel’s Database Population System

      August 8, 2025
      Recent

      Establishing Consistent Data Foundations with Laravel’s Database Population System

      August 8, 2025

      Generate Postman Collections from Laravel Routes

      August 8, 2025

      This Week in Laravel: Free Laravel Idea, Laracon News, and More

      August 8, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      Lenovo Legion Go 2 vs Legion Go — How Do These Gaming Handhelds Compare Based on Rumored Specs?

      August 8, 2025
      Recent

      Lenovo Legion Go 2 vs Legion Go — How Do These Gaming Handhelds Compare Based on Rumored Specs?

      August 8, 2025

      9 Default Settings in Windows 11 You Didn’t Know Could Affect Performance and Privacy

      August 8, 2025

      DICE Responds to Battlefield 6 Community: Key Updates on Map Flow and Class Mechanics

      August 8, 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

    Establishing Consistent Data Foundations with Laravel’s Database Population System

    August 8, 2025
    Development

    Generate Postman Collections from Laravel Routes

    August 8, 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

    Microsoft may have pulled the plug on the Surface Laptop Studio 2

    Operating Systems

    Stealth Falcon Exploits New Zero-Day (CVE-2025-33053) in Sophisticated Cyberespionage Campaign

    Security

    How to Switch Screens on Windows: The Complete Guide to Multi-Monitor Productivity 

    Operating Systems

    CVE-2025-24916 – Tenable Network Monitor Local Privilege Escalation

    Common Vulnerabilities and Exposures (CVEs)

    Highlights

    CVE-2025-53375 – Dokploy File Access Vulnerability

    July 7, 2025

    CVE ID : CVE-2025-53375

    Published : July 7, 2025, 4:15 p.m. | 1 hour, 8 minutes ago

    Description : Dokploy is a self-hostable Platform as a Service (PaaS) that simplifies the deployment and management of applications and databases. An authenticated attacker can read any file that the Traefik process user can access (e.g., /etc/passwd, application source, environment variable files containing credentials and secrets). This may lead to full compromise of other services or lateral movement. This vulnerability is fixed in 0.23.7.

    Severity: 0.0 | NA

    Visit the link for more details, such as CVSS details, affected products, timeline, and more…

    CVE-2025-5520 – Open5GS AMF/MME Reachable Assertion Vulnerability

    June 3, 2025

    SuperTuxKart 1.5 Release Candidate Now Available

    May 28, 2025

    Microsoft gives up, extends Windows 10’s support for free if you meet the requirements

    June 24, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

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